ThinkPHP is an excellent PHP development framework that provides rich extension functions to facilitate developers to quickly complete various needs. During development, file uploading is a common requirement. But by default, ThinkPHP upload file size is limited. So, how to modify the upload file size?
1. PHP.ini configuration modification
The first thing to note is that there is a limit on the upload file size in the PHP.ini file. Therefore, we can modify the size of the uploaded file by modifying the PHP.ini file. The specific steps are as follows:
2. Modify the application configuration file
Modifying the PHP.ini file is global. If you only want to modify the upload file size in a certain application, you need to modify the ThinkPHP application configuration. document. The specific steps are as follows:
'upload_max_filesize' => '10M', 'post_max_size' => '10M',
3. Modify the verification rules in the controller
In ThinkPHP, the file type, size, etc. are generally verified when uploading files. We can also modify the controller's Validate rules to modify upload file size. The specific steps are as follows:
$validate = new \think\Validate([ 'file' => 'fileSize:10485760|fileExt:xlsx,xls', ]);
Summary:
Whether it is by modifying the PHP.ini configuration or modifying the application configuration file or controller verification rules, as long as you master the method of modifying the size of the uploaded file, during the subsequent development process Easily handle various file upload needs. It should be noted that increasing the size of uploaded files will also increase server pressure and risks, so please adjust carefully.
The above is the detailed content of How to modify the size of uploaded files in thinkphp. For more information, please follow other related articles on the PHP Chinese website!