2 回答
![?](http://img1.sycdn.imooc.com/54584f9d0001219b02200220-100-100.jpg)
TA贡献1804条经验 获得超8个赞
做过类似的东西,是在onUploadStart中判断的,弄了好久才搞定
'onUploadStart': function (file) {
var myself = this;
if(已存在){
myself.cancelUpload(file.id);
$('#' + file.id).remove();
}
}
是根据uploadify源码中改的
// Triggered right before a file is uploaded
onUploadStart: function (file) {
// Load the swfupload settings
var settings = this.settings;
var timer = new Date();
this.timer = timer.getTime();
this.bytesLoaded = 0;
if (this.queueData.uploadQueue.length == 0) {
this.queueData.uploadSize = file.size;
}
if (settings.checkExisting) {
$.ajax({
type: 'POST',
async: false,
url: settings.checkExisting,
data: { filename: file.name },
success: function (data) {
if (data == 1) {
var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
if (!overwrite) {
this.cancelUpload(file.id);
$('#' + file.id).remove();
if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
if (this.queueData.uploadQueue[0] == '*') {
this.startUpload();
} else {
this.startUpload(this.queueData.uploadQueue.shift());
}
}
}
}
}
});
}
添加回答
举报