Upload max size in PHP?

六月ゝ 毕业季﹏ 提交于 2019-12-17 02:49:16

问题


Is it possible for the upload of ~100 MB files using PHP?

If so, what changes need to occur in the configuration file (php.ini)?

Sri


回答1:


The following options are relevant:

  • PHP: upload_max_filesize (in php.ini or .htaccess only, won't work using ini_set())
  • PHP: post_max_size (ditto)
  • PHP: max_input_time (ditto, thanks @Thorstein, forgot this one)

and possibly

  • Apache: LimitRequestBody



回答2:


In your php.ini adjust the value of:

file_uploads = On
upload_max_filesize = 100M //needs to be in {x}M format

And allow larger post size:

post_max_size = 100M



回答3:


To allow for larger uploads with PHP you must change a few settings in the php.ini file (upload_max_filesize, max_input_time, memory_limit, max_execution_time, post_max_size). You can find your php.ini file under you PHP installation directory, and more information about the required settings here.




回答4:


Just wanted to add that if your project also use ngnix, you may have to add client_max_body_size 100M; to your nginx.conf since nginx defaults to only 1 MB - in addition to the PHP settings mentioned above. I use a ".user.ini" file at root level of my projects to change the few settings I want to override from the default "php.ini" file.

I'm using dokku and found it at /etc/nginx/nginx.conf and added the extra line via nano nginx.conf.
I don't directly use nginx, but my buildpack adds it.

Hope this helps someone :)




回答5:


You just need to change the timeout of the server and the max file size in the php.ini file.

http://blog.jc21.com/2007-05-03/change-the-maximum-upload-size-with-php/

EDIT: You may not need to change the timeout of the server as that really would depend on which server you are running things on.



来源:https://stackoverflow.com/questions/3263480/upload-max-size-in-php

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