Blueimp jQuery File Upload插件-“清空文件上传"比分PHP [英] Blueimp jQuery File Upload plugin - "Empty file upload" result PHP
问题描述
这里是插件: https://github.com/blueimp/jQuery-File-Up >
上传文件后,我在从插件获取所需的响应时遇到问题.
在带有插件的页面上,我有以下内容
$('#fileupload').fileupload(
'option',
{
'maxNumberOfFiles' :1,
'url' : '/admin/upload_handler.php'
}
);
在upload_handler.php
中,我成功地从$ _FILES检索了上载的文件并进行了处理,然后使用JSON发送回了响应.我已经使用Firebug确认响应的格式正确:
[
{
"url" : "image_url",
"thumbnail_url" : "image_th_url",
"delete_url" : "test",
"delete_type" : "DELETE",
"name" : "foobar.jpg",
"size" : 7419
}
]
但是回调无法找到文件数组,并且出现错误:空文件上传结果".我觉得我在这里缺少了一些关键的东西-我在文档,论坛或Stack Overflow中找不到任何东西.感谢您的帮助.
自插件版本5起,json响应已更改:https://github.com/blueimp/jQuery-File-Upload
I'm having a problem getting the response I want from the plugin after uploading a file.
On the page with the plugin, I have the following
$('#fileupload').fileupload(
'option',
{
'maxNumberOfFiles' :1,
'url' : '/admin/upload_handler.php'
}
);
In upload_handler.php
I successfully retrieve the uploaded files from $_FILES and do stuff, then send a response back in JSON. I've confirmed using Firebug that the response is in the proper format:
[
{
"url" : "image_url",
"thumbnail_url" : "image_th_url",
"delete_url" : "test",
"delete_type" : "DELETE",
"name" : "foobar.jpg",
"size" : 7419
}
]
But the callback can't find the files array, and I get the error: 'Empty file upload result'. I feel like I'm missing something crucial here--I can't find anything in the docs, forums, or Stack Overflow. I appreciate any help.
Since the version 5 of the plugin, the json response has changed: https://github.com/blueimp/jQuery-File-Upload/wiki/JSON-Response
So you just have tweak your upload class with:
$filejson = new stdClass();
$filejson->files[] = $fileArray;
return json_encode($filejson);
And you're done
这篇关于Blueimp jQuery File Upload插件-“清空文件上传"比分PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!