What are the points you must know when uploading php files ,. What are the points you must know when uploading php files? this article mainly describes the configuration points related to PHP file uploading. The php file upload function configuration mainly involves the php file upload in the php. ini configuration file,
This article mainly describes the configuration points related to PHP file upload. The php file upload function configuration mainly involvesUpload_tmp_dir,Upload_max_filesize,Post_max_size.
Open the php. ini configuration file and findFile Uploads
File_uploads = On
HTTP File upload is allowed by default. this option cannot be set to OFF.
Upload_tmp_dir =
The default value is null. this option is easy to forget when you manually configure the PHP runtime environment. if this option is not configured, the file upload function cannot be implemented, this option sets the temporary directory for storing files during File upload. you must assign a value to this option, for example, upload_tmp_dir = '/leapsoulcn', which indicates that there is a leapsoulcn directory under the C directory, like session configuration, if you are in a linux environment, you must grant this directory write permission.
How do I upload large files larger than 8 MB?
Uploading large files mainly involves configurationUpload_max_filesizeAndPost_max_sizeTwo options.
Php. the default file upload size in the ini configuration file is 2 MB. a common mistake for php beginners is to set the form area with the maximum file size when writing the file upload function, that is, the maximum value allowed to upload files. The value of max_file_size (hidden value range) specifies the size of the uploaded files. In fact, this value can be bypassed by others. for security reasons, it is best to use php. configure the upload_max_filesize option in the ini configuration file to set the file upload size.
DefaultUpload_max_filesize = 2 MThat is, the file size is 2 MB. if you want to upload a file larger than 8 MB, such as 20 MB, you must setUpload_max_filesize = 20 M.
However, if you set upload_max_filesize = 20 m, you still cannot upload large files. you must modifyPost_max_sizeIndicates the maximum length of data bytes allowed for POST. the default value is 8 MB. If the POST data exceeds the limit, $ _ POST and $ _ FILES will be empty. To upload a large file, you must set the option value to be greater than the value of the upload_max_filesize command,I usually set the value of upload_max_filesize to be equal to that of post_max_size.. In addition, if the memory limit is enabled, this value should be smaller than the value of the memory_limit option.
Other precautions for file Upload
When uploading a large file, you may feel that the upload speed is slow. if it exceeds a certain period of time, an error occurs when the script execution exceeds 30 seconds. this is because it is in the php. ini configuration file.Max_execution_timeThe configuration option is tricky. it indicates the maximum allowed execution time (in seconds) for each script, and 0 indicates no limit. You can adjust the value of max_execution_time appropriately. it is not recommended to set it to 0.
So far, in php. the PHP Tutorial for configuring file upload options in the ini configuration file is complete. the file upload function can be implemented through the above steps, practices and learning, and the PHP program.
Tips: This article mainly describes the configuration points related to PHP file upload. The php file upload function configuration mainly involves the php. ini configuration file...