用 Nginx 做为代理服务器, 后端为 apache2. 设置允许上传最大为 100M 的文件, 需要的朋友可以参考下
用 Nginx 做为代理服务器, 后端为 apache2. 设置允许上传最大为 100M 的文件.
1. Nginx 配置:
- http {
- ......
- client_max_body_size 100m;
- ......
- }
2. PHP 配置文件
- ......
- ; Maximum execution time of each script, in seconds
- ; http://php.net/max-execution-time
- ; Note: This directive is hardcoded to 0 for the CLI SAPI
- max_execution_time = 0
- ......
- [Data Handling]
- ; Maximum size of POST data that PHP will accept.
- ; http://php.net/post-max-size
- post_max_size = 100M
- ......
[File Uploads]
- ; Maximum allowed size for uploaded files
- upload_max_filesize = 100M
- ......
3. $_FILES[file]['error'] 信息说明
UPLOAD_ERR_OK
其值为 0, 没有错误发生, 文件上传成功
UPLOAD_ERR_INI_SIZE
其值为 1, 上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值
UPLOAD_ERR_FORM_SIZE
其值为 2, 上传文件的大小超过了 html 表单中 MAX_FILE_SIZE 选项指定的值
UPLOAD_ERR_PARTIAL
其值为 3, 文件只有部分被上传
UPLOAD_ERR_NO_FILE
其值为 4, 没有文件被上传
UPLOAD_ERR_NO_TMP_DIR
其值为 6, 找不到临时文件夹 PHP 4.3.10 和 PHP 5.0.3 引进
UPLOAD_ERR_CANT_WRITE
其值为 7, 文件写入失败 PHP 5.1.0 引进
来源: https://www.php1.cn/detail/php-09dd95ad07.html