Configure PHP.ini to implement PHP file upload function,
This article describes how to configure PHP.ini to implement PHP file upload functionality. These include options such as Upload_tmp_dir, Upload_max_filesize, and post_max_size in the php.ini configuration file, which are key to the success or failure of a file upload. Let's take a php.5.3.5 version of Windows as an example.
php.ini file Upload feature configuration options description
Open the PHP.ini configuration file with the Text tool (recommended editplus), find the file uploads, and have the following 3 options in this area:
File_uploads = On
Whether to allow HTTP file uploads. The default is on to allow HTTP file uploads, and this option cannot be set to OFF.
Upload_tmp_dir =
Temporary storage directory for file uploads. If not specified, PHP will use the system default temp directory. This option is empty by default, this option is also easy to forget when manually configuring PHP runtime environment, if you do not configure this option, the file upload function will not be implemented, you must assign this option, such as Upload_tmp_dir = "D:/fileuploadtmp", The representative has a fileuploadtmp directory under the D-Disk directory, and reads and writes permissions to this directory.
Upload_max_filesize = 2M
The maximum size of the uploaded file. The default value of this option is 2M, that is, file upload size is 2M, if you want to upload a 50M file, you must set upload_max_filesize = 50M.
However, only setting upload_max_filesize = 50M will not enable uploading of large files, and we must also modify the Post_max_size option in the php.ini file.
Continue to find Data handling in php.ini, there are 1 options in this area:
Post_max_size = 8M
Refers to the maximum value that can be received by a form post to PHP, including all values in the form. The default is 8M. If the post data exceeds the limit, then $_post and $_files will be empty.
To upload a large file, you must set the value of the option value greater than the upload_max_filesize option, for example you set upload_max_filesize = 50M, where you can put post_max_size = 100M.
In addition, if memory limits are enabled, the value should be less than the value of the Memory_limit option.
Continue to find Resource Limits in php.ini, there are 3 options in this area:
Max_execution_time = 30
Maximum time value (in seconds) for each PHP page to run, default 30 seconds. When we upload a larger file, such as 50M files, it is likely to take a few minutes to upload, but php default page the longest execution time is 30 seconds, more than 30 seconds, the script will stop execution, resulting in a situation where the Web page cannot be opened. So we can set the value larger, such as Max_execution_time = 600. If set to 0, no time limit is indicated.
Max_input_time = 60
The time (in seconds) that each PHP script takes to parse the request data, which defaults to 60 seconds. When we upload large files, we can set this value to a larger size. If set to 0, no time limit is indicated.
Memory_limit = 128M
This option is used to set the maximum memory space that a single PHP script can request. This helps prevent poorly written scripts from consuming the available memory on the optical server. If you do not need any in-memory restrictions, set it to-1.
php5.2.0 Previous version default 8M; The php.5.2.0 version defaults to 16M. PHP 5.2.0 After the default version is 128M;
php.ini Configuring the Upload file feature example
Suppose you want to upload a large file of 50M. The configuration php.ini is as follows:
File_uploads = On
Upload_tmp_dir = "D:/fileuploadtmp"
Upload_max_filesize = 50M
Post_max_size = 100M
Max_execution_time = 600
Max_input_time = 600
Memory_limit = 128M
Tip: Need to keep Memory_limit > Post_max_size > Upload_max_filesize
This example is for reference only, you can adjust according to the actual situation.
http://www.bkjia.com/PHPjc/913099.html www.bkjia.com true http://www.bkjia.com/PHPjc/913099.html techarticle configure PHP.ini to implement PHP file upload function, this article describes how to configure PHP.ini to implement PHP file upload function. This involves the Upload_tmp_dir, upload_max_file ... in the php.ini configuration file .