我正在尝试解决plupload的问题,我在上传窗口中显示错误,由upload.php生成。无论我做什么,我都无法在窗口中创建错误图标。虽然警报工作正常,但文件始终标记为成功。有人可以告诉我,我在这里做错了什么?
upload.php的错误是die('{"jsonrpc" : "2.0", "error" : {"code": 500, "message": "File upload failed."}, "id" : "id"}');
这是javascript:
// Convert divs to queue widgets when the DOM is ready
$(function() {
// Setup html5 version
$("#html5_uploader").pluploadQueue({
// General settings
runtimes : 'html5',
url : 'upload.php',
max_file_size : '2000mb',
chunk_size : '1mb',
unique_names : false,
// Specify what files to browse for
filters : [
{title : "Video Clips", extensions : "mov,avi,mpg,flv,mp4"},
{title : "Audio Files", extensions : "mp3,wav"},
{title : "Executable Files", extensions : "exe"},
{title : "Zip Files", extensions : "zip,rar"}
],
preinit: attachCallbacks
});
// attach callbacks for FileUploaded and Error
function attachCallbacks(uploader) {
uploader.bind('FileUploaded', function(up, file, response) {
response = jQuery.parseJSON( response.response );
alert(response.error.code);
if (response.error.code == '500') {
alert (response.error.message);
//alert (file.id);
$('#' + file.id).attr('class', 'plupload_failed').find('a').css('display', 'none').attr('title', response.error.message);
file.status = plupload.FAILED;
} else {
alert("yoohoo");
$('#' + file.id).attr('class', 'plupload_done').find('a').css('display', 'none').attr('title', 'Success');
file.status = plupload.DONE;
}
});
}
});
感谢。
答案 0 :(得分:3)
如果其他人正在寻找解决方案,请点击此处:http://www.plupload.com/punbb/viewtopic.php?id=1710
问题是您在preinit部分中使用了FileUploaded事件。您应该在init部分绑定您的事件。
(LeandroJF回答)