This article mainly introduces the reasons and solutions for PHP large file upload failure. It has certain reference value. Now I share it with everyone. Friends in need can refer to it
1. Open php.ini
2. Find post_max_size: (modify upload size limit)
The maximum value for form submission. This item does not limit the size of a single uploaded file, but The default is 8m for limiting the submitted data of the entire form. Set it to the value you need. It is recommended that this parameter be set larger than upload_max_filesize
3. Find file uploads :(Modify upload switch restrictions)
Whether to allow file uploading via http switch, confirm file_uploads = on
4. Find upload_tmp_dir:(Modify upload temporary file restrictions)
The file is uploaded to the place where temporary files are stored on the server. If not specified, the system's default temporary folder will be used. If the system error prompts "xxx temporary directory xxx", you need to set a valid directory for this directory. If no error is reported, don't worry.
5. Find upload_max_filesize:(Modify upload size limit)
The maximum allowed upload file size, the default is 2m, Set this parameter to the value you need. It is recommended not to exceed the post_max_size value, because it is controlled by the post_max_size value (even if upload_max_filesize is set to 1g,
and post_max_size is only set to 2m, it is greater than 2m The file still cannot be uploaded because it is controlled by the post_max_size value)
6. If you want to upload a file larger than 8m, you also need to set the following parameters: (Modify upload time limit)
Find max_execution_time = 600; The maximum time value (seconds) for each php page to run, the default is 30 seconds
max_input_time = 600; The maximum time required for each PHP page to receive data, the default is 60 seconds
memory_limit = 8m; The maximum memory required for each PHP page, the default 8m
nginx method to upload large files solution
1.Client_body_buffer_size should be set as large as possible. This is based on speed considerations. If the uploaded file always has to be written to the disk because it is set too small, the speed will be too slow.
2.client_body_temp_path The path must have writable permissions. This is an obvious mistake. Just correct it
3.client_max_body_size sets the maximum value for uploaded files. This is based on security considerations. We believe that normal users will not or basically will not upload files that are too large.
Can be set to client_max_body_size 100m; or set this value according to your own business.
1. Open php.ini
##2. Find post_max_size: (modify upload size limit)
Maximum value for form submission. This item does not limit the size of a single uploaded file, but limits the submission data of the entire form. The default is 8m. Set it to what you need. Value, it is recommended that this parameter be set larger than upload_max_filesize
3. Find file uploads:(Modify the upload switch limit)
Whether to allow file uploading via http switch, confirm file_uploads = on
4. Find upload_tmp_dir:(modify upload temporary file Restrictions)
# Files are uploaded to the place where temporary files are stored on the server. If not specified, the system default temporary folder will be used. If the system error prompts "xxx "Temporary directory xxx", you need to set a valid directory for this directory. If no error is reported, don't worry.
5. Find upload_max_filesize:(Modify the upload size limit )
The maximum allowed upload file size, the default is 2m, set it to the value you need. This parameter is not recommended to exceed the post_max_size value, because it is controlled by post_max_size value (even if upload_max_filesize is set to 1g,
When post_max_size is only set to 2m, files larger than 2m still cannot be uploaded because it is controlled by the post_max_size value)
6. If you want To upload files larger than 8m, you also need to set the following parameters: (modify the upload time limit)
Look for max_execution_time = 600; the maximum time for each PHP page to run Value (seconds), default is 30 seconds
max_input_time = 600; Maximum time required for each php page to receive data, default is 60 seconds
memory_limit = 8m; The maximum memory required for each php page, the default is 8m
nginx method to upload large files solution
1.client_body_buffer_size Try to set it as large as possible. This is based on speed considerations. If the setting is too small, the uploaded file always needs to be written to the disk, and the speed will be reduced. It's just too slow.
2.client_body_temp_path The path must have writable permissions. This is an obvious mistake. Just correct it
3.client_max_body_size sets the maximum value for uploaded files. This is based on security considerations. We believe that normal users will not or basically will not upload files that are too large.
Can be set to client_max_body_size 100m; or set this value according to your own business.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
The above is the detailed content of Why can't php large files be uploaded?. For more information, please follow other related articles on the PHP Chinese website!