Javascript-ajax PHP detects file size after submitting a form using form data

Source: Internet
Author: User
After Ajax submits the form using form data, PHP cannot get the files and other post data that the form submitted, after discovering that the file values set in PHP are exceeded.

No more than can be obtained, but the normal form submission seems to be able to get uploaded file information.

Reply content:

After Ajax submits the form using form data, PHP cannot get the files and other post data that the form submitted, after discovering that the file values set in PHP are exceeded.

No more than can be obtained, but the normal form submission seems to be able to get uploaded file information.

If the file is a big problem, it should be in front of the first to detect, if the simple backend to get the file size:

if($_FILES['file']['size'] > 10485760) { // 這裡是 bytes 等於 10mb   // do something}

If the server is nginx , the upload file exceeds client_max_body_size The parameter set value, this request will not be forwarded to PHP processing, at the server level is intercepted, visual inspection of your situation may be related to this!

PHP.ini set in the Post_max_size and Upload_max_filesize, beyond the size of the set, the request can not be normal processing by PHP.

Ajax cannot upload files.

If you are jquery you can consider plugin Ajaxfileupload

  • 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.