Yesterday, I shared a PHP tutorial on how to configure the session function in php.ini in PHP website development, today continue to share some key php.ini configuration when using PHP to upload the file.
Speaking of the file upload in the php.ini configuration, in fact, before introducing PHP file Upload function code example tutorial and jquery ajaxupload implementation file Upload function code example tutorial when I have mentioned. PHP File Upload function Configuration mainly involves the php.ini configuration file Upload_tmp_dir, Upload_max_filesize, post_max_size and other options.
php.ini File Upload function configuration options description
Open php.ini configuration file to find file uploads
File_uploads = On
HTTP file uploads are allowed by default, and this option cannot be set to OFF.
Upload_tmp_dir =
The default is NULL, this option in the manual configuration of the PHP operating environment, also easy to forget, if not configured this option, file upload function can not be implemented, this option is set file upload files in the temporary directory, you must give this option to assign values, such as Upload_tmp_dir = '/ LEAPSOULCN ', the representative in the C disk directory has a LEAPSOULCN directory, and session configuration like, if you are in the Linux environment, you must give this directory writable permissions.
How do I upload a large file over 8M?
Uploading large files mainly involves configuring upload_max_filesize and post_max_size two options.
Default file upload size in php.ini profile for 2m,php Beginners An error is to make the file upload function by setting the maximum size of the upload file form area, that is, the maximum allowable upload file, Max_file_ Size (hidden range) value to specify the size of the upload file, in fact, other people can bypass this value, so security, it is best to configure the Upload_max_filesize option in the php.ini configuration file, set the file upload size.
Default upload_max_filesize = 2M, that is, the size of the file upload is 2M, if you want to upload more than 8M of files, such as 20M, you must set upload_max_filesize = 20M.
But the light setting upload_max_filesize = 20M still cannot achieve the upload function of the large file, you must modify the Post_max_size option in the php.ini configuration file, which represents the maximum byte length of the data allowed to post, and 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 this option is greater than the value of the upload_max_filesize instruction, I generally set upload_max_filesize and post_max_size values equal. In addition, if the memory limit is enabled, the value should be less than the value of the Memory_limit option.
Additional Considerations for file uploads
When uploading large files, you will have a slow upload feeling, when more than a certain amount of time, will report the script execution more than 30 seconds of error, because in the php.ini configuration file max_execution_time configuration options in the mischief, which represents the maximum allowable execution time per script (seconds), 0 Indicates no limit. You can adjust the Max_execution_time value appropriately, not recommend setting to 0.
At this point, in the php.ini configuration file upload options to configure the PHP tutorial is finished, through the above steps of practice and learning, combined with PHP programs, file Upload function can be achieved.
Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.