Javascript 无法使用CodeIgniter中的drop zone上载大zip文件

Javascript 无法使用CodeIgniter中的drop zone上载大zip文件,javascript,php,jquery,ajax,codeigniter,Javascript,Php,Jquery,Ajax,Codeigniter,我正在尝试使用drop zone上传zip文件。上传小尺寸的zip文件很好。但是,对于超过5MB的zip,无法上载。不知何故,上传过程停留在100%,并一直保持到手动刷新页面 您可以在这里看到: 拖动文件后,在100%的情况下,它会被卡住,并在控制台中出现错误 错误: HTML 首先,您的代码错误不清楚。您可以在调用JSON.parse之前打印变量数据,如下所示,以显示原始错误 onUploadSuccess: function (id, data) { consol

我正在尝试使用drop zone上传zip文件。上传小尺寸的zip文件很好。但是,对于超过5MB的zip,无法上载。不知何故,上传过程停留在100%,并一直保持到手动刷新页面

您可以在这里看到:

拖动文件后,在100%的情况下,它会被卡住,并在控制台中出现错误

错误:

HTML


首先,您的代码错误不清楚。您可以在调用JSON.parse之前打印变量数据,如下所示,以显示原始错误

onUploadSuccess: function (id, data) {
            console.log(data);
        },
我认为在返回结果之前,您没有在Codeigniter中将内容类型头设置为JSON

只需在PHP文件中添加以下代码,然后重试

$this->response->setContentType('Content-Type: application/json');
并在成功上传文件后返回响应

return json_encode(['status'=>'ok','path'=>'file-path']);
如果它不起作用,那么首先尝试这个包中给出的演示代码。
这个问题的答案在这里。 我将服务器限制改为这种方式,现在工作正常

memory_limit = 250M //The maximum amount of memory in bytes a script is allowed to allocate.
max_input_time = 600 //The maximum time in seconds a script is allowed to parse input data.
max_execution_time = 600 //The maximum time in seconds a script is allowed to run before it is terminated.

post_max_size = 200M //The maximum size in bytes of data that can be posted with the POST method. Typically, should be larger than upload_max_filesize and smaller than memory_limit.
upload_max_filesize = 100M //The maximum size in bytes of an uploaded file.
$this->response->setContentType('Content-Type: application/json');
return json_encode(['status'=>'ok','path'=>'file-path']);
memory_limit = 250M //The maximum amount of memory in bytes a script is allowed to allocate.
max_input_time = 600 //The maximum time in seconds a script is allowed to parse input data.
max_execution_time = 600 //The maximum time in seconds a script is allowed to run before it is terminated.

post_max_size = 200M //The maximum size in bytes of data that can be posted with the POST method. Typically, should be larger than upload_max_filesize and smaller than memory_limit.
upload_max_filesize = 100M //The maximum size in bytes of an uploaded file.