简体   繁体   English

JQuery AJAX 上传文件不适用于超过 10 MB 的文件

[英]JQuery AJAX upload file does not work with files more than 10 MB

I've been stumped with this issue for the past 3 hours.在过去的 3 个小时里,我一直被这个问题难倒。 I've looked at countless guides and posts to no avail.我看了无数的指南和帖子都无济于事。

I have a system where users are able to upload files.我有一个用户可以上传文件的系统。 Once they select a file, I want to upload the file (via PHP file) and show the user the upload progress.一旦他们选择了一个文件,我想上传文件(通过 PHP 文件)并向用户显示上传进度。 I've tried to do this using $.ajax (using FormData) and JQuery Form plugin.我尝试使用$.ajax (使用 FormData)和 JQuery Form 插件来做到这一点。 They both work with smaller files that are less than 10 MB, but I've found that when I try to upload a file that's more than 10 MB my PHP file receives none of the information ( $_POST or $_FILE ).它们都可以处理小于 10 MB 的较小文件,但我发现当我尝试上传大于 10 MB 的文件时,我的 PHP 文件没有收到任何信息( $_POST$_FILE )。

How can I fix this issue, or how can I allow users to upload files and show them an accurate upload progress bar?如何解决此问题,或者如何允许用户上传文件并向他们显示准确的上传进度条?

Thanks in advance.提前致谢。

You should check two vars in your PHP script: 您应该在PHP脚本中检查两个变量:

ini_get('post_max_size') , ini_get('upload_max_filesize') and if the user is able to upload multiple files ini_get('max_file_uploads') . ini_get('post_max_size')ini_get('upload_max_filesize')以及用户是否可以上传多个文件ini_get('max_file_uploads') If one or all limits are below your expectations you should raise them in your php.ini 如果一个或所有限制都低于您的期望,则应在php.ini中提高它们

Edit: Added upload_max_filesize to the list. 编辑:将upload_max_filesize添加到列表中。

运行ini_get('post_max_size')我发现托管公司将其限制为8MB ,因此我使用php_value post_max_size 128M通过.htaccess将其增加到128MB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM