Home > Article > Backend Development > How to modify the file uploaded by php that is too large
During the process of file upload, sometimes the uploaded file is too large. The default file upload size of PHP is 2M, and it cannot upload files that are too large. So how should we deal with it?
The following are some methods to modify the php.ini file:
Method 1: Modify the php.ini file
upload_max_filesize=100M post_max_size=100M
3. Save and close the php.ini file.
Method 2: Modify through .htaccess file
1. Open the root directory of your website and find the .htaccess file.
2. Open the file with a text editor and add the following lines:
php_value upload_max_filesize 100M php_value post_max_size 100M
3. Save and close the .htaccess file.
After the above operations, you can successfully upload overly large files. Of course, if you do not want to change the maximum upload file size by modifying the php.ini file, you can also set the upload file size by adding the following content in the PHP script:
ini_set('post_max_size', '100M') ini_set('upload_max_filesize', '100M')
Use the ini_set() function in PHP to configure upload_max_filesize way, if you want to temporarily change the maximum upload size, others won't be able to see the change and need to be specified in the script.
Summary: File upload is a frequently used function in Web development, and the default upload file size of PHP is 2M. We need to modify the php.ini file or add PHP script configuration to complete the function of uploading large files.
The above is the detailed content of How to modify the file uploaded by php that is too large. For more information, please follow other related articles on the PHP Chinese website!