Solve the problem that nginx+php-fpm can't upload files

  
                  Uploading a file is a function that we will need for any web development, but the nginx+php-fpm of the small configuration can't upload the file. Let's take a look at the solution.

Solution

location ~ \\.php$ { root /var/www/html/public; client_max_body_size 50M; client_body_temp_path /tmp; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $ Document_root$fastcgi_script_name; include fastcgi_params;

}

Attachment: Don't look for it, I have tried many on the Internet! Always tell Firebug to reach the Post request size limit

Modify post_max_size in PHP.ini upload_max_filesize max_execution_time max_input_time

Open the php.ini file and restart the server after the modification. Upload the file under test. . . . (Hey, is there a large file?)

1. A temporary directory for storing files when the file is uploaded. Must be a directory writable by the PHP process owner user. If not specified, PHP uses the system default php.ini file in upload_tmp_dir to indicate the temporary directory where the files uploaded by PHP are placed. To upload a file, you must ensure that the server does not close the temporary file and has write access to the folder

2. max_execution_time

The variable max_execution_time sets the PHP waiting for the script to execute before forcing the script to terminate. Time, this time is calculated in seconds. This variable is very useful when the script enters an infinite loop state. However, this feature can also cause an operation to fail when there is a legitimate activity that takes a long time to complete (for example, uploading a large file). In this case, you must consider increasing the value of this variable to avoid PHP closing the script while the script is performing some important process.

Modified to: max_execution_time =800

3, file_uploads = On (the original question does not need to be set) 4, upload_max_filesize = 2M modified to 800M 5, a variable related to the form submission is Post_max_size, which controls the maximum amount of data PHP can receive in a form submission using the POST method. It seems unlikely that you will need to change the default 8 MB to be larger. Instead, it should be appropriately reduced to a more realistic value. However, if you want to use the PHP file upload function, you need to change this value to be larger than upload_max_filesize. Also modified as: post_max_size =900M

6, max_input_time

This variable limits the time in seconds to receive data via POST, GET, and PUT. If the application is running on a low-speed link, you need to increase this value to accommodate more time required to receive the data. Modify to: max_input_time =900

7, memory_limit =10M
< In order to avoid running a large amount of system available memory for running scripts, PHP allows you to define memory usage limits. Use the memory_limit variable to specify the maximum memory capacity that a single script can use. The value of the variable memory_limit (do not exceed the maximum value in the server). Modify to: memory_limit =128M

Copyright © Windows knowledge All Rights Reserved