Solve the problem of nginx+php uploading large files by setting Nginx client_max_body_size:
Use Nginx to do webserver, upload large files need to pay special attention to client_max_body_size this parameter, otherwise it will be interrupted in Nginx request, in PHP is unable to record to access.
General upload large file flow:
First modify the php.ini file:
Parameter setting description
File_uploads on whether to allow the switch to upload files over HTTP. The default is on, which is open
upload_tmp_dir– files are uploaded to the server where temporary files are stored, and if not specified, the system default Temp folder is used
upload_max_filesize 8m Wang Wen Business, that is, the maximum size allowed to upload files. Default is 2M
Post_max_size 8m refers to the maximum value that can be received by a form post to PHP, including all values in the form. Default is 8M
Description
Generally speaking, after setting up the above four parameters, it is not a problem to upload <=8m files under normal network conditions.
However, if you want to upload a large file of >8m, it is not necessarily possible to set the above four items. Unless your network really has a 100m/s upload speed, you still have to set the following parameters.
Max_execution_time 600 Maximum time value per php page (seconds), default 30 seconds
Max_input_time 600 maximum time per PHP page to receive data, default 60 seconds
Memory_limit 8m max memory eaten per PHP page, default 8M
But still can't, because of webserver with Nginx, Google a bit, found in Nginx conf added a parameter:
The default is 1M, you need to increase the words.
Add a sentence in the nginx.conf
client_max_body_size 30m;
Restart can
30m indicates the maximum upload 30M, how much to set the size.
Set the size limit of file uploads in Nginx