Home > Article > Backend Development > How to set the size of uploaded files in PHP
This article mainly introduces how to set the size of uploaded files in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.
Solution:
First:
Check the following line in php.ini:
upload_max_filesize = 8M post_max_size = 10M memory_limit = 20M
Also confirm the uploaded ff9c23ada1bcecdd1a0fb5d5a0f18437 Similar to the following line
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
Second:
If it is apache 2, you need to modify the LimitRequestBody 524288 in
/etc/httpd/conf.d/php.conf
to make 524288 (=512×1024) larger, for example 5M (=5×1024×1024)
In addition: PHP’s maximum execution time is also a possible factor.
It can also be set temporarily through the php file. The code is as follows:
<?php ini_set('max_execution_time', '600'); ini_set('post_max_size ', '100M'); // 好像设置不成功,不起作用 ini_set('upload_max_filesize', '200M'); // 好像设置不成功,不起作用 ?>
Open php.ini, first find
;;;;;;;;;;;;;; ;;;
; File Uploads ;
;;;;;;;;;;;;;;;;;;
area has the following parameters that affect file upload:
file_uploads = on ; Switch whether to allow file uploads via HTTP. The default is ON which means open
upload_tmp_dir; files are uploaded to the place where temporary files are stored on the server. If not specified, the system default temporary folder will be used
upload_max_filesize = 200m ;Wangwen business, that is, the maximum size of the file allowed to be uploaded. The default is 2M
at
##;;;;;;;;;;;;;;;;;;;;; Data Handling ;
; ;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;;
Related recommendations:
How to solve the problem that the temporary folder cannot be found when PHP uploads files
php upload In-depth file analysis
php method to upload files to a remote server
The above is the detailed content of How to set the size of uploaded files in PHP. For more information, please follow other related articles on the PHP Chinese website!