function
uploadTowedAccreditInit(){
$(
"#uploadTowedAccredit"
).uploadify({
&
#39;hideButton':'true',
&
#39;preventCaching' : 'true',
&
#39;checkExisting':'true',
&
#39;swf': SWF,
&
#39;uploader':uploadImg,
&
#39;debug':false,
&
#39;multi': true,
&
#39;method': 'post',
&
#39;preventCaching' : true,
&
#39;removeCompleted' : true,
&
#39;removeTimeout' : 10,
&
#39;requeueErrors' : true,
&
#39;successTimeout' : 30,
&
#39;uploadLimit' : ${towedAccreditPicMax},
&
#39;fileObjName' : 'Filedata',
&
#39;fileSizeLimit' : '1024KB',
&
#39;fileTypeDesc' : 'Image Files',
&
#39;fileTypeExts' : '*.jpg;*.png',
&
#39;height': 24,
&
#39;width':73,
&
#39;buttonText' : '上传附件',
&
#39;auto': true,
&
#39;buttonClass':'uploada btn-fff-24',
&
#39;onSWFReady' : function() {
},
&
#39;onInit':function(){
},
&
#39;onSelect' : function() {
},
&
#39;onCancel' : function(file) {
},
&
#39;onCheck': function(event,data,key) {
},
&
#39;onUploadStart' : function(file) {
$(&
#39;.uploadify-queue').html('');
},
&
#39;onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
$(&
#39;.uploadify-queue').html('');
$(
"#uploadTowedAccreditLinkTip"
).html('<em></em>上传中...');
},
&
#39;onUploadComplete' : function(file) {
$(&
#39;.uploadify-queue').html('');
$(
"#uploadTowedAccreditLinkTip"
).html('<em></em>上传成功,待提交');
},
&
#39;onUploadSuccess' : function(file, data, response) {
var
obj = eval(&
#39;(' + data + ')');
var
result=obj.result;
if
(result==
"true"
){
var
filename=obj.filename;
$(&
#39;.uploadify-queue').html('');
$(&
#39;#towedAccreditp').append("<p class='img-wrap'><img width='112' height='84' alt='' src='"+filename+"'><p class='mask'><em></em><span></span></p></p>");
}
},
&
#39;onUploadError' : function(file, errorCode, errorMsg, errorString) {
switch
(errorCode) {
case
-100:
alert(
"上传的文件数量已经超出系统限制的"
+$(&
#39;#uploadTowedAccredit').uploadify('settings','queueSizeLimit')+"个文件!");
break
;
case
-110:
alert(
"文件 ["
+file.name+
"] 大小超出系统限制的"
+$(&
#39;#uploadTowedAccredit').uploadify('settings','fileSizeLimit')+"大小!");
break
;
case
-120:
alert(
"文件 ["
+file.name+
"] 大小异常!"
);
break
;
case
-130:
alert(
"文件 ["
+file.name+
"] 类型不正确!"
);
break
;
}
},
&
#39;onSelectError' : function(file, errorCode, errorMsg) {
var
msgText =
"上传失败\n"
;
switch
(errorCode) {
case
SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
var
towedAccreditpLen = $(
"#towedAccreditp"
).children().length;
msgText +=
"每次最多上传 "
+ $(&
#39;#uploadTowedAccredit').uploadify('settings','uploadLimit') + "个文件";
break
;
case
SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
msgText +=
"文件大小超过限制( "
+ $(&
#39;#uploadTowedAccredit').uploadify('settings','fileSizeLimit') + " )";
break
;
case
SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
msgText +=
"文件大小为0"
;
break
;
case
SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
msgText +=
"文件格式不正确,仅限 "
+ $(&
#39;#uploadTowedAccredit').uploadify('settings','fileTypeExts');
break
;
default
:
msgText +=
"错误代码:"
+ errorCode +
"\n"
+ errorMsg;
}
alert(msgText);
}
});
var
obj = $(
"#uploadTowedAccredit"
).children().eq(0);
if
(obj.attr(&
#39;type')!= "application/x-shockwave-flash"){
alert(&
#39;系统检测到您的浏览器没有安装flash插件,为了你能够正常上传图片,建议你安装flash');
return
;
}
$(
"#uploadTowedAccredit"
).css(
"float"
,
"left"
);
};