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";
?>
Ensure your
form
has the following attributeenctype="multipart/form-data"
.If you are trying to upload an array of files then you may need to increase
max_file_uploads
inphp.ini
which is by default set to20
Note:
max_file_uploads
can NOT be changed outside php.ini. See PHP "Bug" #50684Make sure your input element has a 'name' attribute.
<input type="file" name="uploadedfile" />
If this is missing the $_FILES will be empty.
I ran into the same issue and found that it was my IDE was part of the issue. I was launching the debugger directly from the IDE (PHPStorm) instead of just using the browser directly. The IDE spawned URL was like this:
and just using:
worked just fine. My set up is PC / Windows 10 / WAMPSERVER 3.0.6 64bit
As far as the HTML you appear to have set that part up correctly. You already have the
enctype="multipart/form-data"
which is very important to have on the form.As far as your
php.ini
setup, sometimes on systems multiplephp.ini
files exist. Be sure you are editing the correct one. I know you said you have configured yourphp.ini
file to have file uploads, but did you also set yourupload_max_filesize
andpost_max_size
to be larger than the file you are trying to upload? So you should have:Does your directory:
"c:\wamp\tmp"
have both read and write permissions? Did you remember to restart Apache after you made thephp.ini
changes?I too had problems with $_FILES empty. The above check-list do not mention MultiViews in .htaccess, httpd.conf or httpd-vhost.conf.
If you have MultiViews set in the options directive for your directory containing the web site, $_FILES will be empty, even though Content-Length header if showing that the file i uploaded.