Can't upload files bigger than 8MB

本秂侑毒 提交于 2019-12-12 02:06:49

问题


I'm trying to make a file upload script and I've been struggling with this problem for a while.

I've read and tried all the SO answers related to this, but to no avail.

Here is what I tried in php. ini:

file_uploads = On
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 100M

In Apache I have:

<Directory /var/www/uploads>
php_value upload_max_filesize 10G
php_value post_max_size 10G
</Directory>

I might have tried something else that doesn't come to mind right now.

I also want to mention that everything under 8MB is uploaded without a problem. Also timeout isn't a problem either as the upload fails in just a few seconds.

P.S. I'm using Cloudflare. Could it be that this is what's blocking my upload?


回答1:


Confirm your location of PHP.ini by creating a test.php file with phpinfo() in it.

Next, check your Apache (LimitRequestBody directive*) and php.ini (upload_max_filesize) limits, so normally those are set higher. Value is in bytes.

Apache 2.0 has a default upload size of 524288,found in the php "include file" /etc/httpd/conf.d/php.conf, to override this value, place the following directive in your httpd.conf virtual host directive:

<Files *.php>
LimitRequestBody 30000000
</Files>

(This example limits request body to 30M)

Apache 1.3 does not have this default, and so you normally have to change only the php.ini (upload_max_filesize,post_max_size) values and the config.ini (maxuploadfilesize) value.

Finally, check RequestReadTimeout setting. More at https://serverfault.com/a/260389




回答2:


sometimes excute time occur problem, use set_time_limit(0);

or

Check the php.ini ini_set('max_execution_time', 0); //0



来源:https://stackoverflow.com/questions/28058742/cant-upload-files-bigger-than-8mb

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