When using Apache to upload files using the PHP file function, the allowable file size is affected by the system configuration. Generally, You need to modify PHP. ini:
- Extension or cancellation of execution time limit:
Max_execution_time is 30 seconds by default. The value is changed to max_execution_time = 0 (0 indicates no limit) or a number greater than the value;
Another way is to add
Set_time_limit ();
To set the longest page execution time.
Set_time_limit (0); // 0 indicates no limit
- Change the value of post_max_size = 2 m (2 m by default) to the desired size, for example:
Post_max_size = 100 m
We usually do this step to solve the problem. In fact, you still need to take a look at the following steps.
- Upload_max_filesize indicates the maximum value of the uploaded file.
Find upload_max_filesize. The default value is 8 Mb.
Upload_max_filesize = 100 m
It should be noted that the post_max_size is better than the upload_max_filesize setting.
Finally, restart Apache after the configuration is complete.
For details, refer to [PHP. ini core configuration options] in the PHP manual 〕
The maximum size of the File Uploaded By upload_max_filesize.
Post_max_size: set the maximum size allowed by post data.
Memory_limit specifies the maximum number of memory bytes that a script can apply.
Parameters Involved in file upload in PHPPHP's default upload limit is 2 MB. to upload files that exceed this setting, you need to adjust some parameters such as PHP and Apache. next, we will briefly introduce some parameters involved in PHP file upload:
Whether to allow file upload over HTTP. On is enabled by default.
Upload_tmp_dir indicates the temporary directory where PHP files are uploaded. to upload files, make sure the server does not have the permission to close the temporary files and write the files to the folder. If not specified, PHP uses the system default value.
Maximum file size that can be uploaded. The default value is 2 MB.
Controls the maximum data size that PHP can receive in a form submission using the POST method. If you want to use the PHP file upload function, you need to change this value to a value greater than upload_max_filesize.
The time for receiving data through post, get, and put is limited in seconds. If the running environment of the application is on the low-speed link, you need to add this value to adapt to the more time required to receive data.
To avoid using a large amount of available memory by running scripts, PHP allows you to define the memory usage limit. Use the memory_limit variable to specify the maximum memory capacity variable memory_limit that can be used by a single script program. The value of memory_limit should be greater than the value of post_max_size.
Max_execution_time sets the time for PHP to wait for the script to be executed before the script is forcibly terminated. The time is calculated in seconds. This variable is useful when the script enters an infinite loop state. However, when there is a legal activity that takes a long time to complete (such as uploading large files), this function will also cause operation failure. In this case, you must consider increasing the value of this variable to prevent PHP from closing the script when the script is executing an important process.
It seems that PHP. INI has to be clear about its powerful functions.