//swf上传需要在onUploadError处理这个失败
$('#' + opts.fileObjName).uploadify('cancel');
'onUploadError': function(file, errorCode, errorMsg, errorString) {
if(errorCode != -280){//取消上传的错误码是-280
$.dialog.error('上传失败,请重试',{txtYes: '我知道了'});
}
}
/*
依赖于jQuery和$.dialog
opts = {
fileObjName:'idCardPositive',
swf: 'uploadify/uploadify.swf',
showProgress: function(progress){},//progress:0-1
checkFile: function(file){},
normalOnSelect: function(){},
normalUploaded: function(id,data),
positionClass: 'file-btn-left',
}
*/
function init(opts){
var maxSize = 5242880;//1024 * 1024 * 5,5M
$('#' + opts.fileObjName).uploadify({
'fileSizeLimit ': maxSize,
'multi': false,//每次只能选择一个文件
'auto': true,/*如果是自动上传,那上传按钮将没用了*/
'fileTypeExts': '*.jpg;*.bmp;*.jpeg;*.png',
'fileTypeDesc': '请选择图像或者视频',
'queueID': 'fileQueue',
'width': 200,
'height': 140,
'buttonText': '',
'fileObjName': opts.fileObjName,//需要修改文件名称
'swf': opts.swf,
'uploader': '/pcapi/user/uploadUserChangeCardImage.htm',
'onSelect' : function(file) {
//有name表示是swf格式文件上传,html5文件上传参数请参考http://www.uploadify.com/documentation/uploadifive/onselect-2/
//需要检测文件类型和大小
if(opts.checkFile(file)){
opts.normalOnSelect(opts.positionClass);
}else{
//swf上传需要在onUploadError处理这个失败
$('#' + opts.fileObjName).uploadify('cancel');
}
},
'onUploadProgress': function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
opts.showProgress(bytesUploaded/bytesTotal);
},
'onUploadError': function(file, errorCode, errorMsg, errorString) {
if(errorCode != -280){//取消上传的错误码是-280
$.dialog.error('上传失败,请重试',{txtYes: '我知道了'});
}
},
'onUploadSuccess': function(file, data) {
opts.normalUploaded(opts.fileObjName,data);
}
});
}
'onAddQueueItem': function(file) {//html5需要自己检测格式和大小
fileCheckResult = opts.checkFile(file);
},
'onSelect' : function(queue) {
if(fileCheckResult){
opts.normalOnSelect(opts.positionClass);
}else{
$('#' + opts.fileObjName).uploadifive('clearQueue');
}
},
/*
依赖于jQuery和$.dialog
opts = {
fileObjName:'idCardPositive',//name和id相同
showProgress: function(progress){},//progress:0-1
checkFile: function(file){},
normalOnSelect: function(positionClass){},
normalUploaded: function(id,data),
positionClass: 'file-btn-left',
}
*/
function init(opts){
var fileCheckResult = true;
var maxSize = 5242880;//1024 * 1024 * 5,5M
$('#' + opts.fileObjName).uploadifive({
'fileSizeLimit ': maxSize,
'multi': false,//每次只能选择一个文件
'auto': true,/*如果是自动上传,那上传按钮将没用了*/
'fileTypeExts': '*.jpg;*.bmp;*.jpeg;*.png',
'fileTypeDesc': '请选择图像或者视频',
'queueID': 'fileQueue',
'width': 200,
'height': 140,
'buttonText': '',
'fileObjName': opts.fileObjName,//需要修改文件名称
'dnd': false,//不允许拖拽
'fileType': 'image/*',
'uploadScript': '/pcapi/user/uploadUserChangeCardImage.htm',
'onAddQueueItem': function(file) {//html5需要自己检测格式和大小
fileCheckResult = opts.checkFile(file);
},
'onSelect' : function(queue) {
if(fileCheckResult){
opts.normalOnSelect(opts.positionClass);
}else{
$('#' + opts.fileObjName).uploadifive('clearQueue');
}
},
'onProgress': function(file, e) {
opts.showProgress(e.loaded / e.total);
},
'onError': function(file, errorCode, errorMsg, errorString) {
$.dialog.error('上传失败,请重试',{txtYes: '我知道了'});
},
'onUploadComplete': function(file, data) {
opts.normalUploaded(opts.fileObjName,data);
}
});
}
<div id='total'>
<input type="file" name="total_upload" id="total_upload" multiple="true" />
</div>
<a href="javascript:$('#total_upload').uploadify('upload', '*')">开始上传</a>
<a href="javascript:$('#total_upload').uploadify('cancel', '*')">全部取消上传</a>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有