Blueimp jQuery File Upload plugin - quot;Empty file uploadquot; result PHP(Blueimp jQuery 文件上传插件——“空文件上传结果 PHP)
问题描述
这是插件:https://github.com/blueimp/jQuery-File-Uploadp>
上传文件后,我无法从插件获取我想要的响应.
在带有插件的页面上,我有以下内容
$('#fileupload').fileupload('选项',{'maxNumberOfFiles' :1,网址":/admin/upload_handler.php"});在 upload_handler.php 中,我成功地从 $_FILES 检索上传的文件并执行操作,然后以 JSON 格式发回响应.我已使用 Firebug 确认响应格式正确:
<代码>[{url":image_url",thumbnail_url":image_th_url",delete_url":测试",删除类型":删除",名称":foobar.jpg",尺寸":7419}]但是回调找不到文件数组,我得到错误:'空文件上传结果'.我觉得我在这里遗漏了一些重要的东西——我在文档、论坛或 Stack Overflow 中找不到任何东西.感谢您的帮助.
从插件版本5开始,json响应发生了变化:https://github.com/blueimp/jQuery-File-Upload/wiki/JSON-Response
所以你只需要调整你的上传类:
$filejson = new stdClass();$filejson->files[] = $fileArray;返回 json_encode($filejson);你已经完成了
Here's the plugin: 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 文件上传插件——“空文件上传"结果 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Blueimp jQuery 文件上传插件——“空文件上传"结果 PHP
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
