取消不用一段uploadify 代碼

Phoenix Phoenix 2018.1.18 00:00 View(108) Comment (0)
function uploadFile(id, mode){
	$("#" +id).uploadify({
		swf : './libs/plugins/uploadify/uploadify.swf',
		uploader : 'manage/uploadifyBackground;jsessionid=${pageContext.session.id}',
		fileObjName : 'file',
		buttonText : '<s:text name="selectFile"></s:text>',
		dataType: 'json',
		fileTypeExts : '*.jpeg;*.gif;*.jpg;*.JPEG;*.GIF;*.JPG;*.png;*.PNG',
		fileTypeDesc : 'Image Files',
		queueSizeLimit : 1,
		auto : true,
		multi : false,
		onUploadStart : function(file) {
			var btn = $("#" + id)
			btn.uploadify("settings", "formData", { 'mode': mode});//给参数赋值  
		},
		onUploadSuccess : function(file, data, response) {
			var data = JSON.parse(data);
			console.log(data)
			if (data.result == '1') {
				var img =$("#" +id).closest(".my-uploadify").find("img");
			img.attr('src', data.file);
			} else if (data.result == '0') {
				var msg = '<s:property value="getText(\'saveFail\')"  
                                           escape="false"/>';
				setFlatMsg({
					'msg' : msg,
					'backColor' : 'lightpink'
				});
			} else if (data.result == "2") {
				var msg = '<s:property value="getText(\'noAuthority\')"  
                                           escape="false"/>';
				setFlatMsg({
					'msg' : msg,
					'backColor' : '#FEFF99'
				});
			} else {
				var msg = data.result;
				setFlatMsg({
					'msg' : msg,
					'backColor' : '#FEFF99',
					'autoFade' : false,
					'textAlign' : 'left',
					'width' : 300
				});
			}
		},
		'onUploadError' : function(file, errorCode, errorMsg, errorString) {
			alert('The file ' + file.name + ' could not be uploaded: ' + 
                               errorString);
		}
	});//end uploadify
}//end Function

 

本文链接 https://www.mangoxo.com/blog/rLo7ePDG 版权所有,转载请保留地址链接,感谢!

Latest Comments :