Home > Backend Development > PHP Tutorial > PHP settings allow large file upload sample code_PHP tutorial

PHP settings allow large file upload sample code_PHP tutorial

WBOY
Release: 2016-07-13 10:36:22
Original
912 people have browsed it

Use Nginx as the proxy server, and the backend is apache2. Set to allow uploading files up to 100M.

1. Nginx configuration:

http {
......
client_max_body_size 100m;
......
}

2. PHP configuration file
......
; 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'] Information description

UPLOAD_ERR_OK
The value is 0, no error occurred, and the file was uploaded successfully.

UPLOAD_ERR_INI_SIZE
The value is 1, and the uploaded file exceeds the value limited by the upload_max_filesize option in php.ini.

UPLOAD_ERR_FORM_SIZE
The value is 2, and the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.

UPLOAD_ERR_PARTIAL
The value is 3, the file is only partially uploaded.

UPLOAD_ERR_NO_FILE
The value is 4, no file was uploaded.

UPLOAD_ERR_NO_TMP_DIR
The value is 6 and the temporary folder cannot be found. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE
The value is 7, file writing failed. Introduced in PHP 5.1.0.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/739774.htmlTechArticleUse Nginx as the proxy server, and the backend is apache2. Set to allow uploading files up to 100M. 1. Nginx Configuration: http { ...... client_max_body_size 100m; ...... } 2. PHP configuration file......
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