Attention:
If you are Apache Server, you should configure the php.ini file in the Apache folder The php file upload feature configuration mainly involves Upload_tmp_dir, upload_max_filesize, post_max_size and other options in the php.ini configuration file.
HTTP file uploads are allowed by default, and this option cannot be set to OFF.
Upload_tmp_dir =
The default is empty, this option is also easy to forget when manually configuring the PHP runtime Environment, if you do not configure this option, the file upload function will not be implemented, this option is set to file upload files temporary directory, you must give this option to assign values, such as Upload_tmp_dir = '/ LEAPSOULCN ', on behalf of the C-disk directory has a LEAPSOULCN directory, and the session configuration, if you are in the Linux environment, you must give this directory writable permissions.
How do I upload large files over 8M?
Uploading large files mainly involves configuring the upload_max_filesize and Post_max_size two options.
PHP.ini the default file upload size in the config file for 2m,php beginners is prone to make a mistake when writing the file upload function by setting the maximum size of the upload file area, that is, the maximum number of files allowed to upload, max_file_ The value of size (hidden range) to specify the size of the upload file, in fact, people can generally 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.
The default upload_max_filesize = 2M, that is, the file upload size is 2M, if you want to upload more than 8M files, such as 20M, you must set upload_max_filesize = 20M.
However, the light setting upload_max_filesize = 20M is not capable of uploading large files, you must modify the Post_max_size option in the php.ini configuration file, which represents the maximum byte length of data that is 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 the option to be greater than the upload_max_filesize instruction, and I generally set the upload_max_filesize and post_max_size values equal. In addition, if memory limits are 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 time, will report the script to execute more than 30 seconds of error, because in the php.ini configuration file max_execution_time configuration options in mischief, which represents the maximum allowable execution time per script (seconds), 0 Indicates no limit. You can adjust the value of the max_execution_time appropriately, and it is not recommended to set to 0.
At this point, the php.ini configuration file in the file upload options to configure the PHP tutorial is complete, through the above steps of practice and learning, combined with PHP program, file Upload function can be achieved.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.