Heim  >  Artikel  >  Backend-Entwicklung  >  调整PHP上传文件大小限制

调整PHP上传文件大小限制

WBOY
WBOYOriginal
2016-07-25 08:52:011202Durchsuche
  1. max_execution_time = 30 ; Maximum execution time of each script, in seconds
  2. max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
  3. ;max_input_nesting_level = 64 ; Maximum input variable nesting level
  4. memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
  5. ; Maximum size of POST data that PHP will accept.
  6. post_max_size = 105M
  7. ; Maximum allowed size for uploaded files.
  8. upload_max_filesize = 100M
复制代码

一般来讲,上传文件时,首先需要保证上传内存,查看PHP.INI默认配置,memory_limit默认是128M,对一次脚本执行可消耗的内存量。如果上传限制100M,那么这么大的内存量而言足够了(还是一般来讲,比如多文件同时上传可能就会不够)。

二、调整执行时间set_time_limit max_execution_time默认设置为30秒,对于上传100M文件而言,目前的网络情况来看,30秒要上传100M文件几乎是不可能的,10M带宽完全对称速率,一秒一兆也需要一分半钟。所以这个设置即使调整也难以估算实际执行时间,而且调整太长对APACHE不太友善。 所以建议不要调整max_execution_time,而只是在PHP程序中使用:set_time_limit(0); 进行临时调整。设置0表示没有时间限制。当然从程序执行角度,设置0是解决了超时问题,但其实并非好的解决办法,如果程序支持断点续传,那么设置600秒或3600秒也似乎是个更好的思路,超时时自动断点续传即可。

三、重启APACHE服务器 service httpd restart 您可能感兴趣的文章: 突破php上传文件大小限制的配置方法 PHP增加文件上传大小的限制 如何取消php文件上传不能大于2M的限制 突破php文件上传大小限制的方法 修改php文件上传大小的限制的方法



Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn