Javascript 精细上传器初始文件列表onStatusComplete空结果
我想做相同的功能发现 但是在onStatusChange回调中,对象为nullJavascript 精细上传器初始文件列表onStatusComplete空结果,javascript,fine-uploader,Javascript,Fine Uploader,我想做相同的功能发现 但是在onStatusChange回调中,对象为null callbacks: { onStatusChange: function(id, oldStatus, newStatus) { console.log('new status of ' + newStatus + ' for ID: ' + id); console.log(this.getItemByFileId(i
callbacks: {
onStatusChange: function(id, oldStatus, newStatus) {
console.log('new status of ' + newStatus + ' for ID: ' + id);
console.log(this.getItemByFileId(id));
}
我得到以下输出
ID:0的上载成功的新状态
fine uploader.min.js:2[fine uploader 5.14.2]在“onStatusChange”回调中捕获异常-无法读取null的属性“className”
我知道服务器的会话响应正常,b/c fine uploader显示我的文件、文件名和删除按钮
我想做的事得到支持了吗
以下是我的完整精细上传代码供参考:
`
var uploader_132963 = new qq.FineUploader({
element: document.getElementById("uploader_132963"),
session: { endpoint: 'https://localhost/session', params : { account: 'DEMO9', index: 1, psuuid: UUID_UPLOAD1},},
template : 'qq-template1',
debug: true,
request : {
endpoint: 'localhost',
},
autoUpload: true,
retry: {
enableAuto: true
},
multiple: false,
concurrent: {
enabled: false
},
chunking: {
concurrent: {
enabled : false,
},
enabled: true,
mandatory: true,
partSize: 2000000,
success: {
endpoint: 'https://localhost/success'
}
},
deleteFile: {
enabled: true,
endpoint: 'https://localhost',
method: 'POST',
},
extraButtons: {
folders: false
},
validation: {
allowedExtensions: ['3g2','asf','avi','bmp','doc','docx','flv','gif','jpeg','jpg','m4a','m4v','mj2','mov','mp3','mp4','pdf','png','ppt','pptx','svg',],
allowEmpty: false,
itemLimit: 1,
sizeLimit: 1024000000,
},
callbacks: {
onStatusChange: function(id, oldStatus, newStatus) {
if (newStatus == qq.status.UPLOAD_SUCCESSFUL) {
var fileItem = this.getItemByFileId(id); // will throw exception here
}
}
}
})
`通过初始文件列表加载文件时,将我的代码移动到onAllComplete回调中会得到所需的结果。onStatusChange在当时的
下似乎没有可用的getItemByFileId函数。它将抛出一个异常
在“onStatusChange”回调中捕获异常-无法读取null的属性“className”
我遇到了与此处描述完全相同的问题。解决方案正如bobflorian所指出的那样。这是我如何处理从服务器加载的两个屏蔽文件和正常上载的文件:
onAllComplete: function( arrSucceeded, arrFailed,) {
if (arrSucceeded!==null && $.isArray(arrSucceeded)){
for (var i=0,x=arrSucceeded.length;i<x;i++){
//Get the template markup for the uploaded file
var fileItem = this.getItemByFileId(arrSucceeded[i]);
//Get the generated uuid. This is the same uuid that we save in the PHP SESSION. It points to the actual uploaded file
var uuid = this.getUuid(arrSucceeded[i]);
}
}
}
onAllComplete:函数(arrcesseded,arrfiled,){
if(arrcesseed!==null&&$.isArray(arrcesseed)){
对于(var i=0,x=0.length;很可能尚未添加文件的DOM元素yet@RayNicholus我认为这就是使用onStatusChange事件的意义所在,元素将在该时间点出现。在中的某个位置向模板添加锚链接。侦听qq.status.UPLOAD\u成功状态更改。在成功,更新锚链接以指向相应的下载终结点。您可以使用getItemByFileId找到特定文件的锚链接。onStatusChange对新文件运行良好,但我正在从初始文件列表(会话)中加载文件,这不会触发“提交”事件。您没有在代码中的任何位置检查UPLOAD_是否成功。这是不正确的。在Fine Uploader中调用所有API方法所需的上下文已为所有事件/回调设置。您误解了错误消息。我也遇到了此问题-当newStatus被“拒绝”时调用getItemByFileId似乎失败