php设置允许大文件上传示例代码_PHP

WBOY
Release: 2016-06-01 11:55:24
Original
996 people have browsed it

用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 引进。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!