Home > Article > Backend Development > How to set size limit for file upload using php
The upload_max_filesize and post_max_size directives determine the maximum file size that PHP allows to be uploaded on the server. By default this value is set to 2M, this value can be increased according to the requirements of the application. It is recommended not to increase this value too high on a shared server. Let's take a look at how to change the maximum upload file size limit in PHP.
##Find the correct How to set size limit for file upload using php.ini
$ How to set size limit for file upload using php -i | grep How to set size limit for file upload using php.iniFor web servers like Apache/Nginx, use the How to set size limit for file upload using phpinfo() function to create a PHP script and access it in the web browser. This will show the location of the How to set size limit for file upload using php.ini file used.
Change the maximum upload file size limit
The upload_max_filesize variable defines the maximum size of files that can be uploaded. The post_max_size variable defines the maximum data size that can be posted at one time. Therefore, upload_max_filesize and post_max_size variables need to be set to change the upload maximum file size in PHP. Edit the How to set size limit for file upload using php.ini file to increase the maximum allowed upload file size. Edit the PHP configuration file "How to set size limit for file upload using php.ini" and increase the size to the following values.; Maximum allowed size for uploaded files. ; http://How to set size limit for file upload using php.net/upload-max-filesize upload_max_filesize = 20M ; Maximum size of POST data that PHP will accept. ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://How to set size limit for file upload using php.net/post-max-size post_max_size = 20MSave the configuration file and restart the web server to reload the changes.
Setting the maximum file upload in PHP
Also, use a single request set max_file_uploads directive to set the maximum number of files that can be uploaded.; 可通过单个请求上传的最大文件数 max_file_uploads = 20
Disabling file uploads in PHP
If our application does not require uploading files, we can disable it by setting Off to the file_uploads directive.; Whether to allow HTTP file uploads. ; http://How to set size limit for file upload using php.net/file-uploadsfile_uploads =Off
The above is the detailed content of How to set size limit for file upload using php. For more information, please follow other related articles on the PHP Chinese website!