Home > Backend Development > PHP Tutorial > javascript - After ajax uses form data to submit the form, php detects the file size

javascript - After ajax uses form data to submit the form, php detects the file size

WBOY
Release: 2016-07-06 13:52:14
Original
936 people have browsed it

After ajax uses form data to submit the form, it is found that after exceeding the file value set in php, php cannot obtain the files and other post data submitted by the form.

It can be obtained within any limit, but it seems that uploaded file information can be obtained by ordinary form submission.

Reply content:

After ajax uses form data to submit the form, it is found that after exceeding the file value set in php, php cannot obtain the files and other post data submitted by the form.

It can be obtained within any limit, but it seems that uploaded file information can be obtained by ordinary form submission.

If the problem is that the file is too large, it should be detected on the front end first. If it is simply a matter of getting the uploaded file size on the back end:

<code class="php">if($_FILES['file']['size'] > 10485760) { // 這裡是 bytes 等於 10mb
   // do something
}</code>
Copy after login

If the server is nginx, and the uploaded file exceeds the value set by the client_max_body_size parameter, this request will not be forwarded to PHP for processing, and will be intercepted at the server level. Visually, your situation may be related to this. relation!

Post_max_size and upload_max_filesize are set in php.ini. After the set size is exceeded, the request cannot be processed normally by PHP.

ajax cannot upload files.

If you are using jQuery, you can consider the plug-in ajaxFileUpload

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template