Heim  >  Artikel  >  Backend-Entwicklung  >  PHP配置文件设置上传大文件

PHP配置文件设置上传大文件

WBOY
WBOYOriginal
2016-07-25 08:54:171063Durchsuche
分享下修改php配置文件以设置大文件上传的方法,突破php大文件上传限制,感兴趣的朋友参考下。

本节内容: 在php配置文件中设置大文件上传选项。

要上传大文件到服务器,推荐使用flash长传组件(100M以内还是不错的)swfupload。

PHP上传文件默认不能满足这个需求,参考如下方法修改。

1,一般的php文件上传,除非文件很小.就像一个5M的文件,很可能要超过一分钟才能上传完. 但在php中,默认的该页最久执行时间为 30 秒.就是说超过30秒,该脚本就停止执行. 这就导致出现 无法打开网页的情况.这时我们可以修改 max_execution_time 在php.ini里查找 max_execution_time

默认是30秒.改为 max_execution_time = 0 0表示没有限制 以上修改的是php上传文件中脚本执行超时时间

2,修改 post_max_size 设定 POST 数据所允许的最大大小。此设定也影响到php上传文件。 php默认的post_max_size 为2M.如果 POST 数据尺寸大于 post_max_size $_POST 和 $_FILES superglobals 便会为空. 查找 post_max_size .改为 post_max_size = 150M

3,很多人都会改了第二步.但php上传文件时最大仍然为 8M. 为什么呢.我们还要改一个参数upload_max_filesize 表示所上传的文件的最大大小。 查找upload_max_filesize,默认为8M改为 upload_max_filesize = 100M

另外,在php文件上传中,post_max_size 大于 upload_max_filesize 为佳。 有了以上的修改,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