附件大小限制
以调整附件大小到100M为例。
nginx
修改 nginx 配置client_max_body_size 100M;
php
需要修改两个参数:post_max_size和upload_max_filesize打印$_FILES['xxx']['error']
UPLOAD_ERR_INI_SIZE其值为 1,上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值。
UPLOAD_ERR_FORM_SIZE其值为 2,上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值。
参考: http://php.net/manual/zh/features.file-upload.errors.php
在错误日志可见,超过附件上传限制大小了:[06-Nov-2017 15:13:15 Asia/Chongqing] PHP Warning: POST Content-Length of xxx bytes exceeds the limit of 52428800 bytes in Unknown on line 0
修改 php.ini,假设其路径为/usr/local/php/etc/php.ini,sed -i 's/post_max_size =.*/post_max_size = 100M/g' /usr/local/php/etc/php.ini
sed -i 's/upload_max_filesize =.*/upload_max_filesize = 100M/g' /usr/local/php/etc/php.ini
请求时间限制
附件过大,可能前端会返回504
nginx
常见错误2017/11/06 15:33:41 [error] 13400#0: *19933 upstream timed out (110: Connection timed out) while reading response header from upstream, client:xxx, server: xxx.com, request: "POST /upload/file HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.com", referrer: "http://xxx.com/download/new"
增加配置fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
phpset_time_limit(300);