Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php环境上传大文件需要注意的事项

php环境上传大文件需要注意的事项

发布时间:2018-09-05   编辑:www.jquerycn.cn
jquery中文网为您提供php环境上传大文件需要注意的事项等资源,欢迎您收藏本站,我们将为您提供最新的php环境上传大文件需要注意的事项资源
如果我们配置不对可能导致大文件无法上传了,像nginx配置不当会导致nginx 502 bad 504 time-out问题了,下面我们一起来看问题的解决办法

公共的环境前段


<form enctype="multipart/form-data" action="upload.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

nginx linux环境注意事项


php环境上传大文件需要注意的事项:

/usr/local/php/etc/php-fpm.conf.default
request_terminate_timeout = 0   //这个是fastcgi的执行时间,默认不限制的
client_max_body_size 256m;

fastcgi_buffer_size 256k;
fastcgi_buffers 16 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
   
fastcgi_connect_timeout 3000;
fastcgi_send_timeout 3000;
fastcgi_read_timeout 3000;

另外PHP也需要配置:

memory_limit 512M
max_execution_time 0
post_max_size 256M
upload_max_filesize 256M


apache windows环境下注意事项

配置php.ini文件 (以上传500M以下大小的文件为例)
查找以下选项并修改->
file_uploads = On ;打开文件上传选项
upload_max_filesize = 500M ;上传文件上限


如果要上传比较大的文件,仅仅以上两条还不够,必须把服务器缓存上限调大,把脚本最大执行时间变长
post_max_size = 500M ;post上限
max_execution_time = 1800 ; Maximum execution time of each script, in seconds脚本最大执行时间
max_input_time = 1800 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)内存上限

您可能感兴趣的文章:
php环境上传大文件需要注意的事项
php.ini文件上传功能配置详解
PHP文件上传大小设置方法
PHP文件上传功能代码实例
php 文件上传实例剖析
php 上传大文件时需要做的设置
突破php文件上传大小限制的方法
linux下php上传文件注意事项
Java开发环境的过去、现在和将来
php项目怎么放到服务器

[关闭]