|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I got a problem of file upload. anybody can help? I just copy the code from php.net, but it still can't work. anybody can help? Thanks! The HTML FORM as below: <html><head></head><body> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="test.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="3000000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> </body></html> The PHP as below: <html><head></head><body><?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = '/var/www/uploads/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo '<pre>'; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { //if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; ?> </body></html> I tried to run the code, the result is: Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => pires.gif [type] => image/gif [tmp_name] => /tmp/phphR5y14 [error] => 0 [size] => 5735 ) ) Then, i tried to replace by a "is_upload_file". Result is okay as below, however, i can't find any "php4vph5i" files upload to /tmp directory. File is valid, and was successfully uploaded. Here is some more debugging info:Array ( [userfile] => Array ( [name] => pires.gif [type] => image/gif [tmp_name] => /tmp/php4vph5i [error] => 0 [size] => 5735 ) ) So, anybody knows the problem caused? I have already set the php.ini as below. ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). upload_tmp_dir = /tmp ; Maximum allowed size for uploaded files. upload_max_filesize = 2M My php version is "4.3.10", apache is "2.0.51", running under the fedora 2. Thanks for your kindly help! Wai |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > File upload problem? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|