Home  >  Article  >  类库下载  >  php: File upload (including setting the file upload size limit)

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

高洛峰
高洛峰Original
2016-10-10 10:36:521566browse

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.



Statement:
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
Previous article:java casual notesNext article:java casual notes