Hi
I have a very simple file upload form and script to handle it (copied verbatim from the php manual, except for the file target location and the script name).
However, it always fails, with an error code in the _FILE array or 6.
Does anyone know what this error is or what I am likely to have set wrong? All that I can find in the docs are errors from 0 to 4 :-(
Also, the tmp_name is always empty (as is the type, but I would expect that as I'm not explicitly setting it).
My config is php5 with apache 2 on linux. My php.ini file has upload_tmp_dir explicitly set to /tmp (permissions on this are 777)
Code as follows :-
1) Form
1 <html>
2 <head><title>Form to test file uploads</title></head>
3
4 <body>
5
6 <form enctype="multipart/form-data" action="uploadHandler.php" method="POST">
7 <!-- MAX_FILE_SIZE must precede the file input field -->
8 <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
9 <!-- Name of input element determines name in $_FILES array -->
10 Send this <input name="userfile" type="file" />
11 <input type="submit" value="Send File" />
12 </form>
13
14 </body>
2) Handler
1 <?php
2 // script to handle file uploads. Files are recieved from uploadForm.php in same directory.
3
4 $uploaddir = '/usr/local/apache2/htdocs/TradEx/uploads/';
5 $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
6
7 echo '<pre>';
8 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
9 {
10 echo "File is valid, and was successfully uploaded.\n";
11 }
12 else
13 {
14 echo "Possible file upload attack!\n";
15 echo 'Here is some more debugging info:';
16 print_r($_FILES);
17 print "</pre>";
18 }
19
20 ?>
3) Output :-
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => MANIFEST
[type] => [tmp_name] => [error] => 6
[size] => 0
)
)
Thanks for any help
Tom
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php