Home  >  Article  >  Backend Development  >  How to set file size upload limit in php

How to set file size upload limit in php

藏色散人
藏色散人Original
2020-07-14 09:34:042838browse

How to set the file size in php: first find and open the "php.ini" configuration file; then set the switch that allows file uploading through HTTP; then find the "upload_max_filesize" item and modify the maximum value of the uploaded file size; Finally, set the maximum value that the form POST can receive to PHP.

How to set file size upload limit in php

php.ini method to modify the size limit of php upload files

Open php.ini, first find

file_uploads = on ;是否允许通过HTTP上传文件的开关。默认为ON即是开
upload_tmp_dir ;文件上传至服务器上存储临时文件的地方,如果没指定就会用系统默认的临时文件夹
upload_max_filesize = 8m ;望文生意,即允许上传文件大小的最大值。默认为2M
post_max_size = 8m ;指通过表单POST给PHP的所能接收的最大值,包括表单里的所有值。默认为8M

Generally, after setting the above four parameters, uploading a file of

But if you want to upload a large file >8M, it will definitely work if you only set the above four items.

Further configure the following parameters

max_execution_time = 600 ;每个PHP页面运行的最大时间值(秒),默认30秒
max_input_time = 600 ;每个PHP页面接收数据所需的最大时间,默认60秒
memory_limit = 8m ;每个PHP页面所吃掉的最大内存,默认8M

After modifying the above parameters, you can upload large files under normal circumstances allowed by the network

max_execution_time = 600
max_input_time = 600
memory_limit = 32m
file_uploads = on
upload_tmp_dir = /tmp
upload_max_filesize = 32m
post_max_size = 32m

More related For knowledge, please visit PHP中文网!

The above is the detailed content of How to set file size upload limit 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