PHP upload problems-php uploading large files mainly involves configuring the upload_max_filesize and post_max_size two options

Source: Internet
Author: User

Today, when uploading a very strange problem, sometimes form submission can get the value, and sometimes not get to, and even ordinary fields are not get, think about still not solved, finally asked the master, the teacher looked very strange, and then asked me Upload_max_ FileSize value changed, I said changed Ah, Master also can not solve. After a while, the teacher asked Post_max_size changed, I said that and upload it doesn't matter, master did not mind me, I still follow their own ideas continue to test, get a half day or not, finally tried the advice of the master, success, the original upload is and post_max_size have relations.

Summary: The default file upload size in the php.ini configuration file is 2M, 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.

PHP upload problems-php uploading large files mainly involves configuring the upload_max_filesize and post_max_size two options

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.