Home > Backend Development > PHP Tutorial > php file upload failed

php file upload failed

王林
Release: 2023-04-07 13:20:01
Original
2974 people have browsed it

php file upload failed

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 limits the submission data of the entire form. The default is 8m. 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 through 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 default temporary folder will be used. If there is an error message from the system, If "xxx temporary directory xxx" is used, you need to set a valid directory for this directory. If no error is reported, don't worry about it

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. It is recommended not to exceed the post_max_size value of this parameter, 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) , 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)

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; Each php page receives data The maximum time required, the default is 60 seconds

memory_limit = 8m; The maximum memory required for each php page, the default is 8m

nginx solution for uploading large files

1. Set the client_body_buffer_size to a larger value. This is based on speed considerations. If the uploaded file always has to be written to the disk because the setting is too small, the speed will be too slow.

2. The client_body_temp_path 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.

Recommended tutorial: PHP video tutorial

The above is the detailed content of php file upload failed. For more information, please follow other related articles on the PHP Chinese website!

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