PHP see only 20 uploading files at a time

廉价感情. 提交于 2019-12-28 01:30:10

问题


When I try to upload more than 20 files at a time, then the web server see only first 20. Any other files are just ignored. What is the problem?

Simple code to try:

<form action="index.php" method="post" enctype="multipart/form-data">
<?php
if($_FILES){
    print_r($_FILES);
}
else{
    for($i = 0; $i < 30; $i++)
    {
        echo '<input type="file" name="file'.$i.'"><br/>';
    }
}
?>
<input type="submit" value="go">
</form>

print_r() output:

Array ( [file0] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpD42.tmp [error] => 0 [size] => 274217 ) [file1] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpD52.tmp [error] => 0 [size] => 274217 ) [file2] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpD73.tmp [error] => 0 [size] => 274217 ) [file3] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpD83.tmp [error] => 0 [size] => 274217 ) [file4] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpD94.tmp [error] => 0 [size] => 274217 ) [file5] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpDB4.tmp [error] => 0 [size] => 274217 ) [file6] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpDC5.tmp [error] => 0 [size] => 274217 ) [file7] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpDE5.tmp [error] => 0 [size] => 274217 ) [file8] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpDF5.tmp [error] => 0 [size] => 274217 ) [file9] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE06.tmp [error] => 0 [size] => 274217 ) [file10] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE26.tmp [error] => 0 [size] => 274217 ) [file11] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE37.tmp [error] => 0 [size] => 274217 ) [file12] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE57.tmp [error] => 0 [size] => 274217 ) [file13] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE68.tmp [error] => 0 [size] => 274217 ) [file14] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE78.tmp [error] => 0 [size] => 274217 ) [file15] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpE98.tmp [error] => 0 [size] => 274217 ) [file16] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpEB9.tmp [error] => 0 [size] => 274217 ) [file17] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpEC9.tmp [error] => 0 [size] => 274217 ) [file18] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpEE9.tmp [error] => 0 [size] => 274217 ) [file19] => Array ( [name] => 39442.jpg [type] => image/jpeg [tmp_name] => W:\tmp\phpEFA.tmp [error] => 0 [size] => 274217 ) )

.htaccess: php_value max_file_uploads 100 - doesn't help

ini_set('max_file_uploads', 100) - doesn't help

I just added line to php.ini on my local server :

max_file_uploads = 100

And it's helped. But I don't think that the hoster change it on client's web server. It would be very cool effect on this value without editing php.ini.


回答1:


Set the max-file-uploads setting higher (yes, it's a 'newish' setting).

It's PHP_INI_SYSTEM, so it can either be set in php.ini or webserver/apache configuration. No .htaccess or 'in-script' access I'm afraid.




回答2:


Recently I came across the same issue, but unfortunately none of the above solutions worked for me. So I think I must share the worked solution here

When I was trying to upload 50+ images, the server was limiting it to 20. (I was working on a Centos Server with PHP 5.3.6)

Setting max_file_uploads = 100 in PHP.ini file didn't help even but the number file upload limit changed to 25

On searching the numeric value 25 in the phpinfo() page, I came across a parameter suhosin.upload.max_uploads with value 25.

Setting suhosin.upload.max_uploads to 100 along with max_file_uploads = 100 in the PHP.ini file worked, now on the server we can upload upto 100 files. (I am not sure if we have any other file where we modify the values suhosin parameters , but setting suhosin values in either php.ini OR php.d/suhosin.ini will work :) )

max_file_uploads = 100    
suhosin.upload.max_uploads=100

http://www.hardened-php.net/suhosin/configuration.html




回答3:


There are limits as to how much PHP can post. See the upload_max_filesize, max_file_uploads, and post_max_size directives.




回答4:


You might be running into post_max_size or upload_max_filesize setting limitations.

You can change them in php.ini (post_max_size should be larger than upload_max_filesize)




回答5:


You can create php.ini file in your website directory on hosting, and write this in it:

max_file_uploads = 400

This is allowed way to overwrite php.ini on most hostings (but not in localhost XAMP, etc.) as far as I tried




回答6:


If you run PHP as Apache module you might want to change it at virtual host level (aka httpd.conf). You need to remember that, being a PHP_INI_SYSTEM directive, you have to use php_admin_value (regular php_value will be ignored). Sample code could be:

<Location "/api">
    php_admin_value max_file_uploads 250
</Location>



回答7:


There is a limit set to 20 by the max_file_uploads configuration option.

http://de3.php.net/manual/en/ini.core.php#ini.max-file-uploads




回答8:


Step 1: If you are working on localhost with Xampp server than open xampp control panel click on config button than open php.ini

Step 2: find max_file_uploads=20

Step 3: Change value 20 with custom value

Step 4: Save this php.ini file and close

Step 5: restart your Apache server by clicking stop and than click on start wait for green color background means apache started successfully

Final test by uploading file using your code



来源:https://stackoverflow.com/questions/6083179/php-see-only-20-uploading-files-at-a-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!