Php settings allow large file upload example code _ PHP Tutorial

Source: Internet
Author: User
Php settings allow large files to upload sample code. Use Nginx as the proxy server, and set the backend to apache2. the maximum size of files uploaded is MB. 1. nginx configuration: http {...... client_max_body_size100m ;......} 2. PHP configuration file... use Nginx as the proxy server, and set the backend to apache2. the maximum size of files uploaded is MB.

1. Nginx configuration:

Http {
......
Client_max_body_size 100 m;
......
}

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 = 100 M

......
[File Uploads]
; Maximum allowed size for uploaded files
Upload_max_filesize = 100 M

......

3. $ _ FILES [file] ['error'] information description

UPLOAD_ERR_ OK
The value is 0. If no error occurs, the file is uploaded successfully.

UPLOAD_ERR_INI_SIZE
The value is 1, and the uploaded file exceeds the limit of 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, and only part of the file is uploaded.

UPLOAD_ERR_NO_FILE
The value is 4 and no file is uploaded.

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

UPLOAD_ERR_CANT_WRITE
If the value is 7, the file fails to be written. PHP 5.1.0 is introduced.

Enabled. the backend allows you to upload files up to MB. 1. nginx configuration: http {...... client_max_body_size 100 m ;......} 2. PHP configuration file ......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.