Home  >  Article  >  Backend Development  >  How to limit the size of uploaded files in php

How to limit the size of uploaded files in php

怪我咯
怪我咯Original
2017-07-07 09:30:332159browse

Sometimes you need to use php to upload relatively large files. This is not possible by default and must be modified according to the following method.

Configure the php.ini file (taking uploading files below 500M in size as an example)
Find the following options and modify them ->
file_uploads = On ;OpenFile uploadOption
upload_max_filesize = 500M;Upload file upper limit

If you want to upload a relatively large file, the above two are not enough, you must add the serverCache Increase the upper limit and lengthen the maximum execution time of the script
post_max_size = 500M; post upper limit
max_execution_time = 1800; Maximum execution time of each script, in seconds Maximum execution time of script Time
max_input_time = 1800; Maximum amount of time each script may spend parsing request data
memory_limit = 128M; Maximum amount of memory a script may consume (128MB)Memory upper limit

The above is the detailed content of How to limit the size of uploaded files in php. For more information, please follow other related articles on the PHP Chinese website!

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