I have WampServer 2 installed on my Windows 7 computer. I'm using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PHP, the $_FILES
array is empty. There is no file in the c:\wamp\tmp
folder. I have configured php.ini
to allow file uploads and such. The tmp
folder has read/write privileges for the current user. I'm stumped.
HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form enctype="multipart/form-data" action="vanilla-upload.php" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
PHP:
<?php
echo 'file count=', count($_FILES),"\n";
var_dump($_FILES);
echo "\n";
?>
No one mentioned this but it helped me out and not many places on the net mention it.
Make sure your php.ini sets the following key:
You'll need to check with your webhost if they want you to use an absolute server file path. You should be able to see other directory examples in your php.ini file to determine this. As soon as I set it I got values in my _FILES object.
Finally make sure that your tmp folder and wherever you are moving files to have the correct permissions so that they can be read and written to.
I got the same problem and none of theme was my error. Check in your .htaccess file, if you got one, if "MultiViews" are enabled. I had to disable them.
I had similar problem and the issue was in wrong value in htaccess as shamittomar mentioned.
Change
php_value post_max_size 10MB
tophp_value post_max_size 10M
I have a same problem looking 2 hours ,is very simple to we check our server configuration first.
Example:
any type of file size is
:20mb
, but ourupload_max_size
is above20mb
but array isnull
. Answer is ourpost_max_size
should be greater thanupload_max_filesize
Here another cause I found: When using JQuery Mobile and the form attribute data-ajax is set to true, the FILES array will be empty. So set data-ajax to false.
Thank you everybody for the vary comprehensive replies. Those are all very helpful. The answer turned out to be something very odd. It turns out that PHP 5.2.11 doesn't like the following:
or
If I change it to
2047M
, the upload works.