php plupload上传失败,PHP-plupload错误生成

这篇博客讨论了在使用plupload库时遇到的一个问题,即上传窗口中无法正确显示由upload.php返回的错误信息。尽管能接收到错误代码,但文件状态始终被标记为成功。解决方案在于将'FileUploaded'事件绑定移到'init'部分,而不是'preinit'。该问题涉及到前端JavaScript和PHP的交互,以及plupload的错误处理机制。

我正在尝试解决plupload的问题,其中我在上载窗口中显示了一个由upload.php生成的错误.无论我做什么,我都无法在窗口中创建错误图标.尽管警报可以正常工作,但文件始终标记为成功.有人可以告诉我我在做什么错吗?

来自我upload.php的错误是die(‘{“ jsonrpc”:“ 2.0”,“ error”:{“ code”:500,“ message”:“文件上传失败.”},“ id”:“ id” }’);

// 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;

}

});

}

});

谢谢.

解决方法:

The problem is that you’re using the FileUploaded event inside the preinit section. You should bind your event on the init section.

(LeandroJF的回答)

标签:plupload,php

来源: https://codeday.me/bug/20191201/2080772.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值