Home > 类库下载 > java类库 > body text

php: File upload (including setting the file upload size limit)

高洛峰
Release: 2016-10-10 10:36:52
Original
1567 people have browsed it

What I wrote today was about file upload. I forgot the correct rules I learned a few days ago and used a very stupid method to judge the format and directly uploaded the code: If the format is incorrect, it will be intercepted directly.

If you want to modify the uploaded file size limit, you can refer to the following methods: php: File upload (including setting the file upload size limit)

1. General file upload, unless the file is very small. Like a 5M file, it is likely to take more than a minute to upload.

But In php, the default maximum execution time of the page is 30 seconds. That is to say, if it exceeds 30 seconds, the script will stop executing.

This will lead to the situation that the web page cannot be opened. At this time, we can modify max_execution_time

in php.ini Find

max_execution_time

The default is 30 seconds. Change to
max_execution_time = 0
0 means no limit
2. Modify post_max_size to set the maximum size allowed for POST data. This setting also affects file uploads.
php default post_max_size is 2M. If the POST data size is greater than post_max_size $_POST and $_FILES superglobals will be empty.
Look for post_max_size. Change to
post_max_size = 150M
3. Many people will change the second step. But upload the file The maximum size is still 8M.
Why? We also need to change a parameter upload_max_filesize to indicate the maximum size of the uploaded file.
Look for upload_max_filesize, the default is 8M and change it to
upload_max_filesize = 100M
In addition, it should be noted that post_max_size is better than upload_max_filesize.



Related labels:
php
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