Why is PHP $_FILES always null
I have HTML like
<form action="send.php" method="post" enctype="multipart/form-data">
<div>
<label for="subject">Subject</label>
<input type="text" name="subject" />
</div开发者_如何学JAVA>
<div>
<label for="image">Image</label>
<input type="file" name="image" />
</div>
<input type="submit" value="Send" />
</form>
I keep getting null
for $_FILES
why is that?
In the form section make sure you have this code: enctype="multipart/form-data"
<?php print_r($_FILES);?>
<form action="" method="post" enctype="multipart/form-data">
<div>
<label for="subject">Subject</label>
<input type="text" name="subject" />
</div>
<div>
<label for="image">Image</label>
<input type="file" name="image" />
</div>
<input type="submit" value="Send" />
</form>
Check the code above:
it should produce the following output:
Array
(
[image] => Array
(
[name] => ezwebin_userguide.pdf
[type] => application/pdf
[tmp_name] => C:\Windows\Temp\php1485.tmp
[error] => 0
[size] => 1073054
)
)
Have you tried echoing more specific data? Ex:
echo $_FILES["file"]["error"]
Or
echo $_FILES["file"]["name"]
Regards.
file_uploads might be off in php.ini. Try this script:
<?php
echo 'file_uploads: '. ini_get('file_uploads'). '<br />';
echo 'upload_tmp_dir: '. ini_get('upload_tmp_dir'). '<br />';
echo 'upload_max_filesize: '. ini_get('upload_max_filesize'). '<br />';
echo 'max_file_uploads: '. ini_get('max_file_uploads'). '<br />';
?>
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.
精彩评论