`
小杨学JAVA
  • 浏览: 904083 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

SWFUpload 初始化插件1.3.2

 
阅读更多
/********************************************************************************************************
 * swfuInit
 *----------------------------------------------------------------------------------------------------
 *	封装swfupload上传
 *	document.write("<script language=\"javascript\" src='..\/js\/j.js' > <\/script>");
 *----------------------------------------------------------------------------------------------------
 * @author Kith Yang
 * @Date 2013-12-16
 * @Version 1.3.2
 * @jQueryVersion 1.4+
 * @SWFUploadVersion 2.0+
 **/
var UN_SWFUpload = UN_SWFUpload || {};
UN_SWFUpload.version = "1.3.2 2013-12-16";
UN_SWFUpload.swfuploadList = {};
UN_SWFUpload.swfuList = [];
UN_SWFUpload.SPLITE = ':';
UN_SWFUpload.ART_DIALOG_VER = art && art.dialog ? art.dialog.fn.version: '';
UN_SWFUpload.movieCount = 0;
UN_SWFUpload.uploadTip;
// expand object
UN_SWFUpload.add = function(id, o) {
	return UN_SWFUpload.swfuploadList[id] = o;
};
UN_SWFUpload.get = function(id) {
	return UN_SWFUpload.swfuploadList[id];
};
UN_SWFUpload.destroy = function(id) {
	if (!id || id == undefined || id == null || id == "") {
		for (var o in UN_SWFUpload.swfuploadList) {
			UN_SWFUpload.swfuploadList[o].destroy();
			if (document.getElementById(o)) {
				document.getElementById(o).innerHTML = '';
			}
		}
	} else {
		UN_SWFUpload.swfuploadList[id].destroy();
		if (document.getElementById(id)) {
			document.getElementById(id).innerHTML = '';
		}
	}
};
UN_SWFUpload.serializeData = function() {
	var _data = new Array();
	for (var o in UN_SWFUpload.swfuploadList) {
		_data.push(UN_SWFUpload.swfuploadList[o].getPostData());
	}
	return _data.join('&');
}; (function($) {
	"use strict";
	$.swfu = $.swfu || {};
	$.extend($.swfu, {
		version: "1.3.2",
		getAccessor: function(obj, expr) {
			/* obj:swfuInit
	    	 * 方法名/方法参数
	    	 * $("#list").swfu('getParam', 'param');
	    	 */
			var ret, p, prm = [],
			i;
			if (typeof expr === 'function') {
				return expr(obj);
			}
			ret = obj[expr];
			if (ret === undefined) {
				try {
					if (typeof expr === 'string') {
						prm = expr.split('.');
					}
					i = prm.length;
					if (i) {
						ret = obj;
						while (ret && i--) {
							p = prm.shift();
							ret = ret[p];
						}
					}
				} catch(e) {}
			}
			return ret;
		},
		htmlDecode: function(value) {
			if (value && (value == '&nbsp;' || value == '&#160;' || (value.length === 1 && value.charCodeAt(0) === 160))) {
				return "";
			}
			return ! value ? value: String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
		},
		htmlEncode: function(value) {
			return ! value ? value: String(value).replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
		},
		format: function(format) { //jqgformat
			var args = $.makeArray(arguments).slice(1);
			if (format === undefined) {
				format = "";
			}
			return format.replace(/\{(\d+)\}/g,
			function(m, i) {
				return args[i];
			});
		},
		isNumeric: function(obj) {
			return ! isNaN(parseFloat(obj)) && isFinite(obj);
		},
		isWindow: function(obj) {
			return obj != null && obj == obj.window;
		},
		extend: function(methods) {
			// swfu可以使用$.swfu.extend({});extend other methods
			$.extend($.fn.swfuInit, methods);
			//			if (!this.no_legacy_api) {
			$.fn.extend(methods);
			//			}
		}
	});
	$.fn.swfuInit = function(settings) {
		if (typeof settings == 'string') {
			// var fn = $.swfuInit[pin];
			var fn = $.swfu.getAccessor($.fn.swfuInit, settings);
			if (!fn) {
				throw ("swfuInit - No such method: " + settings);
			}
			var args = $.makeArray(arguments).slice(1);
			return fn.apply(this, args);
		}
		return this.each(function() {
			var elem = $(this);
			if (!elem || elem.length == 0) {
				alert('该对象不存在.');
				return;
			}
			if (this._swfu) {
				return;
			}
			/* 合并默认参数和用户自定义参数 */
			var p = $.extend(true, {},
			$.fn.swfuInit.defaults, settings || {});
			var _swfu = new SRMSwfu(elem, p);
			_swfu.generate();
			// expandable object
			this._swfu = _swfu;
			this.st = p;
		});
		// return _swfu;
	};
	/**
     * $("#list").getParam(id);
     * $("#list").swfu('getParam', 'selarrrow');
     * typeof($t.p[pName]) != "undefined" ? $t.p[pName] : null;
     */
	$.swfu.extend({
		getSwfu: function() {
			//  
			return this[0]._swfu;
		},
		getSwfuParam: function(pName) {
			// this 为 swfuInit
			var $t = this[0];
			if (!$t || !$t._swfu) {
				return;
			}
			if (!pName) {
				return $t.st;
			} else {
				var ret = typeof($t.st[pName]) != "undefined" ? $t.st[pName] : (typeof($t._swfu[pName]) != "undefined" ? $t._swfu[pName] : null);
				art.dialog.alert(ret);
				return ret;
			}
		},
		destroySwfu: function() {
			if (this[0]._swfu != null) {
				this[0]._swfu.destroy();
			}
		},
		getSwfuSerializeData: function() {
			return this[0]._swfu.getPostData();
		},
		getFileIdArr: function() {
			return this[0]._swfu.fileIdValArr;
		},
		getUploadFileNameArr: function() {
			return this[0]._swfu.uploadFileNameValArr;
		},
		getPicturePathArr: function() {
			return this[0]._swfu.picturePathValArr;
		},
		getPictureSizeArr: function() {
			return this[0]._swfu.pictureSizeValArr;
		}
	});
	/**
     * 对外默认参数
     */
	$.fn.swfuInit.defaults = {
		// 文件ID参数名称
		fileId: 'fileId',
		// 上传控件ID参数名称
		businessId: 'businessId',
		// 附件ID,submit to server
		appendixId: 'appendixId',
		// 附件源文件名,
		uploadFileName: 'uploadFileName',
		// 附件重命名后 文件名
		oldPath: 'oldPath',
		// 上传文件时 的临时路径
		picturePath: 'picturePath',
		// 上传文件的大小 单位:字节
		pictureSize: 'pictureSize',
		// 上传控件ID参数值
		businessIdVal: '',
		// 文件ID参数值
		fileIdVal: [],
		// 附件ID,submit to server,多个附件ID以数组形式
		appendixIdVal: [],
		// 附件源文件名,
		uploadFileNameVal: [],
		// 附件重命名后 文件名
		oldPathVal: [],
		// 上传文件时 的临时路径
		picturePathVal: [],
		// 上传文件的大小 单位:字节
		pictureSizeVal: [],
		// 上传按钮后的描述信息
		descInfo: '',
		// 文件的存放路径
		filePath: '',
		// 是否多选
		multiple: true,
		// 上传文件URL
		uploadFileUrl: "../upload/upload.action",
		// 删除文件URL
		delFileUrl: "../upload/delTempFile.action",
		// 提交文件域的参数名称
		filePostName: 'uploadFile',
		// 允许上传文件的类型,以 ; 分割,*.jpg;*.doc
		fileTyps: '*.*',
		fileTypesDesc: 'All File',
		// 默认单位是KB
		fileSizeLimit: '10 MB',
		fileUploadLimit: 10000,
		fileQueueLimit: 10,
		postParams: {},
		downFile: function(serverData, filePath, originalName) {
			/*
        	 * url:ServerData
        	 * filePath:Renamed FileName
        	 * originalName:OriginalFileName
        	 */
			// 下载temp文件
			if (!filePath || filePath == '') {
				if (serverData && serverData.indexOf(UN_SWFUpload.SPLITE) >= 0) {
					var urlArr = serverData.split(UN_SWFUpload.SPLITE);
					for (var i = 0; i < urlArr.length; i++) {
						if (urlArr[i] && urlArr[i] != '') {
							window.open("../upload/download.action?fileUrl=" + urlArr[i]);
						}
					}
				} else {
					window.open("../upload/download.action?fileUrl=" + serverData);
				}
			} else {
				if (serverData && serverData.indexOf(UN_SWFUpload.SPLITE) >= 0) {
					var urlArr = serverData.split(UN_SWFUpload.SPLITE);
					for (var i = 0; i < urlArr.length; i++) {
						if (urlArr[i] && urlArr[i] != '') {
							window.open("../upload/download.action?fileUrl=" + urlArr[i] + "&filePath=" + filePath);
						}
					}
				} else {
					window.open("../upload/download.action?fileUrl=" + serverData + "&filePath=" + filePath)
				}
			}
		},
		showTip: false,
		showPercent: false,
		uploadSuccedHandle: function(postData) {}
	};
	/*
     * 私有函数
     */
	SRMSwfu = function(elem, settings) {
		this.settings = settings;
		// 下载文件的保存路径
		this.filePath = settings.filePath,
		this.uploadDiv = elem;
		this.prefixName = elem.attr("id");
		this.prefixIndex = UN_SWFUpload.movieCount++;
		this.contextName = elem.attr("id");
		this.progressTarget = elem.attr("id") + "fsUploadProgress";
		this.cancelButtonId = elem.attr("id") + "btnCancel";
		this.buttonId = elem.attr("id") + "spanButtonPlaceHolder";
		this.divStatusId = elem.attr("id") + "divStatus";
		this.biddingFileId = elem.attr("id") + "biddingFile";
		this.delFileButtonId = elem.attr("id") + "delFileButton";
		this.filePostName = settings.filePostName ? settings.filePostName: "uploadFile";
		this.postParams = settings.postParams;
		// 已经上传成功后的文件名
		this.SWF_SELECT_FILE_NAME = "";
		this.swfuObject = {};
		// 事件队列
		this.eventQueue = [];
		// 一次选择的文件数量
		this.selectFileCount = 0;
		// 已上传文件list
		this.fileList = [];
		// 各个参数Array(argumentArray instanceof Array)
		this.fileIdValArr = (settings.fileIdVal instanceof Array) ? settings.fileIdVal: (settings.fileIdVal ? [settings.fileIdVal] : []);
		this.appendixIdValArr = (settings.appendixIdVal instanceof Array) ? settings.appendixIdVal: (settings.appendixIdVal ? [settings.appendixIdVal] : []);
		this.uploadFileNameValArr = (settings.uploadFileNameVal instanceof Array) ? settings.uploadFileNameVal: (settings.uploadFileNameVal ? [settings.uploadFileNameVal] : []);
		this.oldPathValArr = (settings.oldPathVal instanceof Array) ? settings.oldPathVal: (settings.oldPathVa ? [settings.oldPathVal] : []);
		this.picturePathValArr = (settings.picturePathVal instanceof Array) ? settings.picturePathVal: (settings.picturePathVal ? [settings.picturePathVal] : []);
		this.pictureSizeValArr = (settings.pictureSizeVal instanceof Array) ? settings.pictureSizeVal: (settings.pictureSizeVal ? [settings.pictureSizeVal] : []);
		this.fileOrder = this.uploadFileNameValArr.length + 1;
		// flash是否初始化完成
		this.falshReady = false;
		// 是否正在上传中
		this.isUploding = false;
		this.fileSizeWithUnit = $.swfu.isNumeric(settings.fileSizeLimit) ? settings.fileSizeLimit + ' KB': settings.fileSizeLimit;
		// 是否有上传过文件
		this.isUploaded = false;
	};

	SRMSwfu.prototype = {
		generate: function() {
			var self = this;
			//	初始化调用SWFUpload对象初始化
			if (self.uploadDiv) {
				self.uploadDiv.html("");
			}
			var htmls = self.getFlashHTML(self.uploadDiv);
			var upObjId = self.prefixName;
			// 所有已经选择的文件名称for多选
			var currSelectFile = '';
			var _swfSet = {
				file_types: self.settings.fileTyps,
				file_types_description: self.settings.fileTypesDesc,
				file_size_limit: self.settings.fileSizeLimit,
				// 最多上传文件数量
				file_upload_limit: self.settings.fileUploadLimit,
				// 队列文件数量
				file_queue_limit: self.settings.fileQueueLimit,
				debug: false,
				// Button settings
				// 单选OR多选
				button_action: self.settings.multiple ? SWFUpload.BUTTON_ACTION.SELECT_FILES: SWFUpload.BUTTON_ACTION.SELECT_FILE,
				button_image_url: "../images/swf_btn_bg.gif",
				button_width: "76",
				button_height: "26",
				button_text: "<span class='theFont'>上传</span>",
				button_text_style: ".theFont { font-size: 11;font-weight:bold;text-align:center; color:#323d1f;background-color:transparent; }",
				button_text_left_padding: 1,
				button_text_top_padding: 4,
				flash_url: "../js/SWFUpload/swfupload.swf",
				upload_url: (self.settings.uploadFileUrl && self.settings.uploadFileUrl != "") ? self.settings.uploadFileUrl: "../upload/upload.action",
				// file_dialog_start_handler : fileDialogStart, 
				file_post_name: self.filePostName,
				custom_settings: {
					progressTarget: self.progressTarget,
					cancelButtonId: self.cancelButtonId

				},
				button_cursor: SWFUpload.CURSOR.HAND,
				post_params: self.postParams,
				button_placeholder_id: self.buttonId,
				// 选中文件后确定后执行,然后file_dialog_complete_handler
				file_queued_handler: function(file) {
					//	    				alert('选中文件后确定后执行file_queued_handler');
					// 当文件选择对话框关闭消失时,如果选择的文件成功加入上传队列,那么针对每个成功加入的文件都会触发一次该事件(N个文件成功加入队列,就触发N次此事件)。
					//	    				this.customSettings.queue = this.customSettings.queue || new Array();
					//	    		        while (this.customSettings.queue.length > 0) {
					//	    		            this.cancelUpload(this.customSettings.queue.pop(), false);
					//	    		        }
					//	    				this.customSettings.queue.push(file);
					var progress = new FileProgress(file, this.customSettings.progressTarget);
					progress.setStatus("Pending...");
					progress.toggleCancel(true, this);
					if (self.settings.multiple) {
						// 多选所有已选 的文件名 
						currSelectFile += file.name + '<br/>';
					} else {
						currSelectFile = file.name;
					}
				},
				file_dialog_complete_handler: function(numFilesSelected, numFilesQueued) {
					if (numFilesSelected > 0 && numFilesQueued > 0) {
						if (self.settings.multiple) {
							self.selectFileCount += numFilesQueued;
							// 多选文件
							var dialog = art.dialog.confirm("确认要上传已选的 " + numFilesQueued + " 个文件吗?",
							function() {
								try {
									// 开始上传
									self.swfuObject.startUpload();
								} catch(ex) {
									dialog.close();
								}
							},
							function() {
								self.swfuObject.cancelQueue();
							});
						} else {
							// 单选文件
							self.selectFileCount = numFilesQueued;
							var dialog = art.dialog.confirm("确认要上传 " + currSelectFile + " 吗?",
							function() {
								try {
									// 单选文件时,删除上一次的文件
									self.delAllFile();
									self.swfuObject.startUpload();
									currSelectFile = '';
								} catch(ex) {
									dialog.close();
								}
							},
							function() {
								// 取消了队列
								self.swfuObject.cancelQueue();
							});
						}
					}
				},
				upload_start_handler: function(file) {
					if (!self.isUploding) {
						self.isUploding = true;
					}
					try {
						//完成上传前的最后验证以及其他你需要的操作,例如添加、修改、删除post数据等。
						var progress = new FileProgress(file, this.customSettings.progressTarget);
						progress.setStatus("Uploading...");
						progress.toggleCancel(true, this);
						if (self.settings.showTip) {
							self.settings.showPercent = false;
							if (!UN_SWFUpload.uploadTip) {
								UN_SWFUpload.uploadTip = //art.dialog.tips('正在上传文件 '+file.name+' ,请稍等...', 60);   
								self.getUploadTips('正在上传文件 ' + file.name);
							} else {
								UN_SWFUpload.uploadTip.content('正在上传文件 ' + file.name).title('上传中...').show();
							}
						}
					} catch(ex) {

}
					return true;
				},
				upload_success_handler: function(file, serverData) {
					/*
    				 * 注意不能
	    			 * this.cancelUpload();
	    			 * 不然导致
	    			 * 一个上传完成(发送file信息,并返回200状态时调用此方法)后,
	    			 * 取消只会取消当前文件的上传,而不是取消整个队列上传,所以每隔一个就会被取消
	    			 * 这个upload_success_handler每个文件上传完成都会调用一次,一个文件上传周期没有完成,还会触发upload_complete_handler;uploadComplete(file)
	    			 * 
    				 */
					if (serverData != null && serverData != "") {
						//	self.isUploaded = !self.isUploaded ? true : self.isUploaded;
						if (!self.isUploaded) {
							self.isUploaded = true;
						}
						try {
							// 将上传成功的file保存
							self.fileList.push(file);
							// 上传成功后加入
							self.SWF_SELECT_FILE_NAME = self.SWF_SELECT_FILE_NAME + file.name + UN_SWFUpload.SPLITE;
							//file.id = "singlefile";    
							var progress = new FileProgress(file, this.customSettings.progressTarget);
							progress.setComplete();
							progress.setStatus("Complete.");
							progress.toggleCancel(false);
							var _fileId = $("#" + self.contextName + "fileId");
							var _uploadFileName = $("#" + self.contextName + self.settings.uploadFileName);
							var _picturePath = $("#" + self.contextName + self.settings.picturePath);
							var _pictureSize = $("#" + self.contextName + self.settings.pictureSize);
							if (self.settings.multiple) {
								_fileId.val(_fileId.val() + file.id + UN_SWFUpload.SPLITE);
								_uploadFileName.val(_uploadFileName.val() + file.name + UN_SWFUpload.SPLITE);
								_picturePath.val(_picturePath.val() + serverData + UN_SWFUpload.SPLITE);
								_pictureSize.val(_pictureSize.val() + file.size + UN_SWFUpload.SPLITE);
								var _biddingFile = $("#" + self.biddingFileId);
								if (_biddingFile.html() == "") {
									$("#" + self.biddingFileId).append('[' + self.fileOrder + '] ' + file.name);
								} else {
									$("#" + self.biddingFileId).append('<br/>' + '[' + self.fileOrder + '] ' + file.name);
								}
								// 保存提交参数
								self.fileIdValArr.push(file.id);
								self.uploadFileNameValArr.push(file.name);
								self.picturePathValArr.push(serverData);
								self.pictureSizeValArr.push(file.size);
							} else {
								// 单选只填入选择的文件
								_fileId.val(file.id);
								_uploadFileName.val(file.name);
								_picturePath.val(serverData);
								_pictureSize.val(file.size);
								// 保存提交参数
								self.fileIdValArr = [file.id];
								self.uploadFileNameValArr = [file.name];
								self.picturePathValArr = [serverData];
								self.pictureSizeValArr = [file.size];
							}
						} catch(e) {
							art.dialog.alert("upload_success_handler" + e);
						}
					}
				},
				upload_complete_handler: function(file) {
					if (SWFUpload.FILE_STATUS.COMPLETE == file.filestatus) {
						self.fileOrder++;
						// 多选文件,清除初始化的文件名,把已经上传的加入文件名value
						// oldPath不需要清空,后台需要删除上次的文件
						if (!self.isUploaded) {
							var _picturePath = $("#" + self.contextName + self.settings.picturePath);
							_picturePath.val("");
							var _uploadFileName = $("#" + self.contextName + self.settings.uploadFileName);
							_uploadFileName.val("");

							self.uploadFileNameValArr = [];
							self.picturePathValArr = [];
							// 选择第一个文件
							self.delAllFile();
						}
					}
					/* 
	    		    	 * 计算上传进度,总数量selectFileCount
	    		    	 */
					if (self.settings.showPercent) {
						var percent = Math.ceil(((self.selectFileCount - this.getStats().files_queued) / self.selectFileCount) * 100);
						if (!UN_SWFUpload.uploadTip) {
							//art.dialog.tips('正在上传文件 '+file.name+' ,请稍等...', 60);
							UN_SWFUpload.uploadTip = self.getUploadTips(percent + ' %');
						} else {
							UN_SWFUpload.uploadTip.content(percent + ' %').show();
						}
					}
					//	    		    	SWFUpload.FILE_STATUS = {
					//	    		    			QUEUED		 : -1,
					//	    		    			IN_PROGRESS	 : -2,
					//	    		    			ERROR		 : -3,
					//	    		    			COMPLETE	 	 : -4,
					//	    		    			CANCELLED	 : -5
					//	    		    		};
					if (this.getStats().files_queued === 0) {
						self.isUploding = false;
						// 队列文件全部上传完成
						document.getElementById(this.customSettings.cancelButtonId).disabled = true;
						//    		    			//  把最后的一个:去掉,java SPLITE最后一个舍弃
						//    		    			var _fileId = $("#"+self.contextName+"fileId");
						//    		    			_fileId.val(self.getLastSplitStr(_fileId.val(), UN_SWFUpload.SPLITE));
						var _uploadFileName = $("#" + self.contextName + self.settings.uploadFileName);
						//    		    			_uploadFileName.val(self.getLastSplitStr(_uploadFileName.val(), UN_SWFUpload.SPLITE));
						var _picturePath = $("#" + self.contextName + self.settings.picturePath);
						//    		    			_picturePath.val(self.getLastSplitStr(_picturePath.val(), UN_SWFUpload.SPLITE));
						//    		    			var _pictureSize = $("#"+self.contextName+self.settings.pictureSize);
						//    		    			_pictureSize.val(self.getLastSplitStr(_pictureSize.val(), UN_SWFUpload.SPLITE));
						// 加入参数ARRAY'
						if (self.SWF_SELECT_FILE_NAME != "") {
							var _biddingFileId = $("#" + self.biddingFileId);
							if (!self.settings.multiple) {
								//    		    					// 单选'<a href="javascript:void(0);">',
								//    		    					_biddingFileId.html('<a href="javascript:void(0);" rname="'+_picturePath.val()+'" fname="'+_uploadFileName.val()+'">'+_uploadFileName.val()+'</a>');
								//    		    					$("#"+self.delFileButtonId).html("删 除");
								self.SWF_SELECT_FILE_NAME = '';
							} else {
								// 多选,下载链接不一样
								// <span><a href="javascript:void(0);">'++'</a></span>
								//    		    					var bidFileNameArr = self.uploadFileNameValArr;
								//    		    					var biddingFileHtmlArr = [];
								//    		    					var picturePathArr = self.picturePathValArr;
								//    		    					var bl = bidFileNameArr.length;
								//    		    					$.each(bidFileNameArr, function(i, v){
								//    		    						if(i != bl - 1) {
								//    		    							// 下载文件获取文件名称rname,fname真实文件名
								//    		    							biddingFileHtmlArr.push('<a href="javascript:void(0);" rname="'+picturePathArr[i]+'" fname="'+v+'">['+(i+1)+']&nbsp;'+v+'</a>&nbsp;<span id="'+i+'delMultipleBtn" class="delMultipleBtn" rname="'+picturePathArr[i]+'" ><a href="javascript:void(0);">删 除</a></span><br/>');
								//    		    						} else {
								//    		    							biddingFileHtmlArr.push('<a href="javascript:void(0);" rname="'+picturePathArr[i]+'" fname="'+v+'">['+(i+1)+']&nbsp;'+v+'</a>&nbsp;<span id="'+i+'delMultipleBtn" class="delMultipleBtn" rname="'+picturePathArr[i]+'" ><a href="javascript:void(0);">删 除</a></span>');
								//    		    						}
								//    		    					});
								// 多选删除所有文件
								if (self.uploadFileNameValArr.length > 1) {
									$("#" + self.delFileButtonId).html("删除所有文件");
								}
							}
							self.getUploadFileNameHtml();

						}
						// 判断队列没有文件,关闭上传tip
						if (self.settings.showTip || self.settings.showPercent) {
							if (UN_SWFUpload.uploadTip) {
								//UN_SWFUpload.uploadTip.content('上传完成.');
								UN_SWFUpload.uploadTip.title('完成');
								UN_SWFUpload.uploadTip.hide();
								//    		    					UN_SWFUpload.uploadTip.button(
								//    		    					    {
								//    		    					        name: '确定',
								//    		    					        callback: function () {
								//    		    					           this.hide();
								//    		    					        },
								//    		    					        disabled: false
								//    		    					    }
								//    		    					)
								self.uploadCompleteTip('上传完成.');
							}
						}
						if (self.settings.uploadSuccedHandle) {
							self.handleEvent("uploadSuccedHandle", self.getPostData());
						}
					}
				},
				file_queue_error_handler: function(file, errorCode, message) {
					// this 已经是swfupload对象
					try {
						if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
							//	    			            art.dialog.alert("文件队列已满,最多可上传 "+this.settings.file_upload_limit+" 个文件.");   
							art.dialog.alert("一次最多能选择  " + this.settings.file_queue_limit + " 个文件.");
							return;
						}
						var progress = new FileProgress(file, this.customSettings.progressTarget);
						progress.setError();
						progress.toggleCancel(false);
						switch (errorCode) {
						case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
							progress.setStatus("File is too big.");
							art.dialog.alert("文件:" + file.name + " 过大,请选择 " + self.fileSizeWithUnit + " 以内的文件进行上传.");
							//this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);   
							break;
						case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
							progress.setStatus("Cannot upload Zero Byte files.");
							art.dialog.alert("文件:" + file.name + " 小大为0KB,请选择大于0KB,小于" + self.fileSizeWithUnit + "的文件进行上传.");
							//this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);   
							break;
						case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
							progress.setStatus("Invalid File Type.");
							art.dialog.alert("请选择类型为 " + this.settings.file_types_description + " 的文件进行上传.");
							//this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);   
							break;
						default:
							if (file !== null) {
								progress.setStatus("Unhandled Error");
							}
							//this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);   
							break;
						}
					} catch(ex) {
						//	    			        this.debug(ex);   
						art.dialog.error("上传文件失败,请刷新页面后重试.");
					}
				},

				//	                upload_progress_handler : function (file, bytesLoaded, bytesTotal) {
				//						try {
				//							var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
				//							var progress = new FileProgress(file, this.customSettings.progressTarget);
				//							progress.setProgress(percent);
				//							progress.setStatus("Uploading...");
				//							$(document.body).prepend(percent);
				//						} catch (ex) {
				//							this.debug(ex);
				//						}
				//	    			},    
				upload_error_handler: function(file, errorCode, message) {
					var progress = new FileProgress(file, this.customSettings.progressTarget);
					progress.setError();
					progress.toggleCancel(false);
					switch (errorCode) {
					case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
						progress.setStatus("Upload Error: " + message);
						art.dialog.alert("文件 " + file.name + " 上传失败, 网络错误. Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
						progress.setStatus("Upload Failed.");
						art.dialog.alert("文件 " + file.name + " 尺寸过大. " + file.size + " 请重新选择. Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.IO_ERROR:
						progress.setStatus("Server (IO) Error");
						art.dialog.alert("服务器I/O设备错误, 文件 " + file.name + ". Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
						progress.setStatus("Security Error");
						art.dialog.alert("服务拒绝上传此文件, 文件 " + file.name + ". Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
						progress.setStatus("Upload limit exceeded.");
						art.dialog.alert("文件队列已满,文件 " + file.name + " 上传失败. Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
						progress.setStatus("Failed Validation.  Upload skipped.");
						art.dialog.alert("文件验证失败,文件 " + file.name + ". Message: " + message);
						break;
					case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
						// If there aren't any files left (they were all cancelled) disable the cancel button   
						if (this.getStats().files_queued === 0) {
							document.getElementById(this.customSettings.cancelButtonId).disabled = true;
						}
						progress.setStatus("Cancelled");
						progress.setCancelled();
						break;
					case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
						progress.setStatus("Stopped");
						break;
					default:
						progress.setStatus("Unhandled Error: " + errorCode);
						art.dialog.alert("未知错误,错误代码  " + errorCode + ", 文件 " + file.name + ", 大小: " + file.size + ". Message: " + message);
						break;
					}
				},
				swfupload_loaded_handler: function() {
					self.falshReady = true;
				}
			};
			self.swfuObject = new SWFUpload(_swfSet);
			self.addToList(self.prefixName, self);
		},
		getFlashHTML: function(divObj) {
			var self = this;
			var delFileButtonHtml = '<span><a style="padding-left:10px;" href="javascript:void(0);" id="' + self.delFileButtonId + '"></a>&nbsp;</span>';
			if (self.uploadFileNameValArr && self.uploadFileNameValArr.length > 1) {
				delFileButtonHtml = '<span><a style="padding-left:10px;" href="javascript:void(0);" id="' + self.delFileButtonId + '">删除所有文件</a>&nbsp;</span>';
			}
			//			// 显示Bidding文件名
			//			var bl = self.uploadFileNameValArr.length;
			//			var _uploadFileNameHtmlArr = [];
			//			$.each(self.uploadFileNameValArr, function(i, v){
			//				if(i != bl - 1) {
			//					_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="'+self.picturePathValArr[i]+'" fname="'+v+'">['+(i+1)+']&nbsp;'+v+'</a>&nbsp;<span id="'+i+'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span><br/>');
			//				} else {
			//					_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="'+self.picturePathValArr[i]+'" fname="'+v+'">['+(i+1)+']&nbsp;'+v+'</a>&nbsp;<span id="'+i+'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span>');
			//				}
			//			});
			var _fileIdValHtml = self.fileIdValArr.join(UN_SWFUpload.SPLITE);
			var _uploadFileNameValue = self.uploadFileNameValArr.join(UN_SWFUpload.SPLITE);
			// 附件IDappendixId
			var _appendixIdValHtml = self.appendixIdValArr.join(UN_SWFUpload.SPLITE);
			// oldPathValArr
			var _oldPathValHtml = self.oldPathValArr.join(UN_SWFUpload.SPLITE);
			// picturePathValArr
			var _picturePathValHtml = self.picturePathValArr.join(UN_SWFUpload.SPLITE);
			// pictureSizeValArr
			var _pictureSizeValHtml = self.pictureSizeValArr.join(UN_SWFUpload.SPLITE);
			var divHtml = [
			// fsUploadProgress
			'<div style="display:none;" id="' + self.progressTarget + '" ></div>', '<div style="display:none;" id="' + self.divStatusId + 'divStatus" ></div>', '<div style="height:28px;">', '<div style="float:left;padding-top:5px;min-width:20px">', '<span id="' + self.biddingFileId + '">' + self.getInitUploadFileNameHtml() + '</span>', delFileButtonHtml, '</div>', '<div style="" id="' + self.buttonId + '"></div>', '<input id="' + self.cancelButtonId + '" type="button" value="Cancel All Uploads" disabled="disabled" style="display:none;"/>', '<span id="' + self.prefixName + 'desc">' + (!self.settings.descInfo || self.settings.descInfo == "" ? "点此按钮可以上传小于 " + self.fileSizeWithUnit + " 的文件": self.settings.descInfo) + '</span>', '<input name="' + self.settings.businessId + '" id="' + self.contextName + self.settings.businessId + '" type="hidden" value="' + self.settings.businessIdVal + '"/>', '<input name="multiple" id="' + self.contextName + 'multiple" type="hidden" value="' + self.settings.multiple + '"/>', '<input name="' + self.settings.fileId + '" id="' + self.contextName + self.settings.fileId + '" type="hidden" value="' + _fileIdValHtml + '"/>', '<input name="' + self.settings.appendixId + '" id="' + self.contextName + self.settings.appendixId + '" type="hidden" value="' + _appendixIdValHtml + '"/>', '<input name="' + self.settings.uploadFileName + '" id="' + self.contextName + self.settings.uploadFileName + '" type="hidden" value="' + _uploadFileNameValue + '"/>', '<input name="' + self.settings.oldPath + '" id="' + self.contextName + self.settings.oldPath + '" type="hidden" value="' + _oldPathValHtml + '"/>', '<input name="' + self.settings.picturePath + '" id="' + self.contextName + self.settings.picturePath + '" type="hidden" value="' + _picturePathValHtml + '"/>', '<input name="' + self.settings.pictureSize + '" id="' + self.contextName + self.settings.pictureSize + '" type="hidden" value="' + _pictureSizeValHtml + '"/>', '<input name="isUploaded" id="' + self.contextName + 'isUploaded" type="hidden" value="' + self.isUploaded + '"/>', '</div>', ''].join("");
			divObj.html(divHtml);
			$("#" + self.delFileButtonId).click(function() {
				self.delAllFile();
			});
			self.bindFileEnvent();
			//			$("#"+self.biddingFileId).children('a').click( function () {
			//				// 每个链接下载
			//				self.handleEvent('downFile', $(this));
			//			});
			//			$("#"+self.biddingFileId).children('span').click( function () {
			//				// 每个链接删除.删除各个参数里的文件,那么这时候删除拼接的字符串,不好操作,那么就将所有的参数不保存到页面,保存到内存中,放入数组/MAP
			//				delMultipleFile($(this));
			//			});
			return divHtml;
		},
		handleEvent: function(handleName, params) {
			var fp = this.filePath;
			if (handleName && handleName == "downFile") {
				this.queueEvent(handleName, [params.attr("rname"), fp, params.attr("fname")]);
			} else {
				if (!params) {
					params = [];
				}
				this.queueEvent(handleName, params);
			}
		},
		delAllFile: function() {
			// 删除了所有文件
			// save 旧文件路径,用来删除旧文件
			var picturePath = this.picturePathValArr.join(UN_SWFUpload.SPLITE);
			// 提交到后台的参数清空
			this.fileIdValArr = [];
			this.uploadFileNameValArr = [];
			this.picturePathValArr = [];
			this.pictureSizeValArr = [];
			// reset input value
			this.refreshFormData();

			$("#" + this.biddingFileId).html("");
			$("#" + this.biddingFileId).html("");
			$("#" + this.delFileButtonId).html("");
			this.SWF_SELECT_FILE_NAME = '';
			this.fileOrder = 1;
			if (picturePath != '') {
				// 删除临时路径的文件
				$.ajax({
					url: this.settings.delFileUrl,
					type: "POST",
					data: {
						'fileUrl': picturePath
					},
					timeout: 10000,
					cache: false,
					success: function(data) {
						try {
							//var json = $.parseJSON(data);

						} catch(e) {}

					},
					error: function() {}
				});
			}
		},
		delMultipleFile: function(clickObj) {
			// 多选删除一个文件
			var swfu = this;
			var _index = $.inArray(clickObj.prev().attr('rname'), swfu.picturePathValArr);
			if (_index >= 0) {
				var _tempPath = swfu.picturePathValArr[_index];
				// 删除这个文件
				swfu.fileIdValArr.splice(_index, 1);
				swfu.uploadFileNameValArr.splice(_index, 1);
				swfu.picturePathValArr.splice(_index, 1);
				swfu.pictureSizeValArr.splice(_index, 1);
				swfu.fileOrder = swfu.uploadFileNameValArr.length + 1;
				// reset input value
				this.refreshFormData();
				var pa = clickObj.prev();
				clickObj.remove();
				pa.remove();
				if (swfu.uploadFileNameValArr.length == 0) {
					$("#" + swfu.delFileButtonId).html("");
				} else {
					// 重新显示文件名并且绑定事件
					swfu.getUploadFileNameHtml();
				}
				// 删除临时路径的文件
				if (_tempPath != '') {
					$.ajax({
						url: swfu.settings.delFileUrl,
						type: "POST",
						data: {
							'fileUrl': _tempPath
						},
						timeout: 10000,
						cache: false,
						success: function(data) {
							try {
								//var json = $.parseJSON(data);

							} catch(e) {}

						},
						error: function() {}
					});
				}
			}
		},
		getInitUploadFileNameHtml: function() {
			var swfu = this;
			// 初始化显示文件html
			var bl = swfu.uploadFileNameValArr.length;
			if (bl > 0) {
				var _orderHtml = swfu.settings.multiple ? '[{0}]': '';
				var _uploadFileNameHtmlArr = [];
				$.each(swfu.uploadFileNameValArr,
				function(i, v) {
					if (i != bl - 1) {
						_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="' + swfu.picturePathValArr[i] + '" fname="' + v + '">' + _orderHtml.format(i + 1) + '&nbsp;' + v + '</a>&nbsp;<span id="' + i + 'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span><br/>');
					} else {
						_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="' + swfu.picturePathValArr[i] + '" fname="' + v + '">' + _orderHtml.format(i + 1) + '&nbsp;' + v + '</a>&nbsp;<span id="' + i + 'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span>');
					}
				});
				return _uploadFileNameHtmlArr.join('');
			} else {
				return '';
			}
		},
		getUploadFileNameHtml: function() {
			// 上传后显示文件html
			var swfu = this;
			var bl = swfu.uploadFileNameValArr.length;
			var _uploadFileNameHtmlArr = [];
			var _orderHtml = swfu.settings.multiple ? '[{0}]': '';
			$.each(swfu.uploadFileNameValArr,
			function(i, v) {
				if (i != bl - 1) {
					_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="' + swfu.picturePathValArr[i] + '" fname="' + v + '">' + _orderHtml.format((i + 1)) + '&nbsp;' + v + '</a>&nbsp;<span id="' + i + 'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span><br/>');
				} else {
					_uploadFileNameHtmlArr.push('<a href="javascript:void(0);" rname="' + swfu.picturePathValArr[i] + '" fname="' + v + '">' + _orderHtml.format((i + 1)) + '&nbsp;' + v + '</a>&nbsp;<span id="' + i + 'delMultipleBtn" class="delMultipleBtn"><a href="javascript:void(0);">删 除</a></span>');
				}
			});
			var _html = _uploadFileNameHtmlArr.join('');
			$("#" + swfu.biddingFileId).html(_html);
			swfu.bindFileEnvent();
			return _html;
		},
		bindFileEnvent: function() {
			// self swfu绑定下载/删除事件
			var self = this;
			$("#" + self.biddingFileId).children('a').click(function() {
				// 每个链接下载
				self.handleEvent('downFile', $(this));
			});
			$("#" + self.biddingFileId).children('span').click(function() {
				// 每个链接删除.删除各个参数里的文件,那么这时候删除拼接的字符串,不好操作,那么就将所有的参数不保存到页面,保存到内存中,放入数组/MAP
				self.delMultipleFile($(this));
			});
		},
		queueEvent: function(handlerName, argumentArray) {
			// 加入队列事件
			//			window.open("../upload/download.action?fileUrl=" + $("#"+this.settings.picturePathVal).val());
			if (argumentArray == undefined) {
				argumentArray = [];
			} else if (! (argumentArray instanceof Array)) {
				argumentArray = [argumentArray];
			}
			var self = this;
			if (typeof this.settings[handlerName] === "function") {
				// Queue the event
				this.eventQueue.push(function() {
					this.settings[handlerName].apply(this, argumentArray);
				});
				// Execute the next queued event
				setTimeout(function() {
					self.executeNextEvent();
				},
				0);

			} else if (this.settings[handlerName] !== null) {
				throw "Event handler '" + handlerName + "' is unknown or is not a function";
			}
		},
		executeNextEvent: function() {
			var f = this.eventQueue ? this.eventQueue.shift() : null;
			if (typeof(f) === "function") {
				f.apply(this);
			}
		},
		addToList: function(swfuName, swfuObj) {
			// 属性名 = 属性值
			UN_SWFUpload.add(swfuName, swfuObj);
			UN_SWFUpload.swfuList.push(swfuObj);
		},
		hide: function() {
			// 隐藏div
			$("#" + this.contextName).hide();
		},
		show: function() {
			// 显示div
			$("#" + this.contextName).show();
		},
		getSwfu: function() {
			return this.swfuObject;
		},
		refreshFormData: function() {
			this.fileIdValArr && this.fileIdValArr.length > 0 ? this.setFileId(this.fileIdValArr.join(UN_SWFUpload.SPLITE)) : this.setFileId('');
			this.uploadFileNameValArr && this.uploadFileNameValArr.length > 0 ? this.setUploadFileName(this.uploadFileNameValArr.join(UN_SWFUpload.SPLITE)) : this.setUploadFileName('');
			this.picturePathValArr && this.picturePathValArr.length > 0 ? this.setPicturePath(this.picturePathValArr.join(UN_SWFUpload.SPLITE)) : this.setPicturePath('');
			this.pictureSizeValArr && this.pictureSizeValArr.length > 0 ? this.setPictureSize(this.pictureSizeValArr.join(UN_SWFUpload.SPLITE)) : this.setPictureSize('');
			this.setIsUploaded(this.isUploaded);
		},
		setFileId: function(val) {
			$("#" + this.contextName + this.settings.fileId).val(val);
		},
		setUploadFileName: function(val) {
			$("#" + this.contextName + this.settings.uploadFileName).val(val);
		},
		setPicturePath: function(val) {
			$("#" + this.contextName + this.settings.picturePath).val(val);
		},
		setPictureSize: function(val) {
			$("#" + this.contextName + this.settings.pictureSize).val(val);
		},
		setIsUploaded: function(val) {
			$("#" + this.contextName + 'isUploaded').val(val);
		},
		destroy: function() {
			if (!this.isUploding) {
				this.delAllFile();
				this.swfuObject.destroy();
				$("#" + this.prefixName).html("");
			} else {
				alert('文件正在上传中,请稍候操作.');
				return;
			}
		},
		cancle: function() {
			this.swfuObject.cancelQueue();
		},
		uploadCompleteTip: function(content, title) {
			return art.dialog.succeed({
				//					id:'uploadCompleteTip',
				//					title:title?title:'消息',
				//					content: content,
				//					icon: 'succeed',
				//					fixed: true,
				//					resize: false,
				//					drag: true	,
				//					width:'200',
				//					esc:false,
				//					yesFn:function (){
				//						return ;
				//					}
			}).content(content);
		},
		getSplitePostion: function(str, sIndex, splite, count) {
			/*
			 * str 从sIndex开始到splite第count出现的位置 之间的位置
			 * 超过最大出现次数,返回最后一次出现的位置
			 * substring包括开始,不包括结束
			 */
			if (!str) {
				return - 1;
			}
			// count不能超过总次数
			var tsrc = str.substring(sIndex);
			var acount = this.getCountInstances(tsrc, splite);
			if (count > acount) {
				// 超过返回最后一次出现的次数
				return this.getSplitePostion(tsrc, 0, splite, acount);
			}
			// str: 是你的原字符串
			// splite: 是你的要找的字符串
			// count: 寻找的次数
			var re = new RegExp(splite, "g");
			while (count--) {
				re.test(tsrc);
			}
			var pos = re.lastIndex - splite.length;
			if (pos < 0) return - 1;
			else return pos;
		},
		getSplitStr: function(str, sIndex, splite, count) {
			if (!str) {
				return '';
			}
			/*
			 * str 从sIndex开始到splite第count出现的位置 之间的 的字符串
			 * substring包括开始,不包括结束
			 */
			var pos = this.getSplitePostion(str, sIndex, splite, count);
			if (pos < 0) {
				// 没有找到,返回str
				return str;
			} else {
				return str.substring(sIndex, pos);
			}

		},
		getCountInstances: function(mainStr, subStr) {
			if (!mainStr) {
				return 0;
			}
			// 字符串在mainstr中出现的次数
			var count = 0;
			var offset = 0;
			do {
				offset = mainStr.indexOf(subStr, offset);
				if (offset != -1) {
					count++;
					offset += subStr.length;
				}
			} while ( offset != - 1 ) return count;
		},
		getLastSplitStr: function(str, split) {
			if (!str) {
				return '';
			}
			// 字符串split在源str最后出现的位置 之间的str
			return this.getSplitStr(str, 0, split, this.getCountInstances(str, split));
		},
		eachArrToString: function(arr, joinStr) {
			var str = '';
			$.each(arr,
			function(i, v) {
				str += str + joinStr;
			});
			return str;
		},
		getPostData: function() {
			// 获取提交参数
			var self = this;
			self.refreshFormData();
			var postArr = ['multiple' + '=' + self.settings.multiple, self.settings.businessId + '=' + self.settings.businessIdVal, self.settings.fileId + '=' + self.fileIdValArr.join(UN_SWFUpload.SPLITE), self.settings.appendixId + '=' + self.appendixIdValArr.join(UN_SWFUpload.SPLITE), self.settings.uploadFileName + '=' + self.uploadFileNameValArr.join(UN_SWFUpload.SPLITE), self.settings.oldPath + '=' + self.oldPathValArr.join(UN_SWFUpload.SPLITE), self.settings.picturePath + '=' + self.picturePathValArr.join(UN_SWFUpload.SPLITE), self.settings.pictureSize + '=' + self.pictureSizeValArr.join(UN_SWFUpload.SPLITE), 'isUploaded' + '=' + self.isUploaded];
			return encodeURIComponent(postArr.join('&'));
		},
		getUploadTips: function(content, title) {
			return art.dialog({
				id: '_uploadTips',
				title: title ? title: '',
				width: 300,
				content: content,
				fixed: true,
				resize: false,
				drag: true,
				yesFn: false,
				noFn: false,
				esc: false
				//				,
				//				button: [
				//				         {
				//				             name: '确定',
				//				             disabled: true
				//				         }
				//				     ]
			});
		}
	};

})(jQuery);

 2013年12月16日, PM 03:27:04 updated

分享到:
评论

相关推荐

    我整理过的Swfupload v2.2插件 demo

    1. `index.php`:这是前端展示页面,其中包含了Swfupload插件的初始化代码和HTML结构。通过引入`swfupload`文件,`index.php`页面能够加载并显示上传按钮。Swfupload插件通常会嵌入到一个或多个`&lt;div&gt;`元素中,用户...

    swfupload图片上传插件制作图片批量上传和单个图片上传代码

    SWFUpload是一款经典的JavaScript与Flash结合的文件上传插件,尤其适用于处理图片上传。它允许用户在网页上实现批量和单个图片的上传功能,提高了用户体验,并且在处理大量文件时,比传统的表单提交方式更为高效。...

    SWFUpload flash上传插件

    * 可以同时上传多个文件;  * 类似AJAX的无刷新上传;  * 可以显示上传进度;  * 良好的浏览器兼容性;  * 兼容其他JavaScript库 (例如:jQuery, Prototype等);  * 支持Flash 8和Flash 9;

    swfupload flash插件上传

    1. JavaScript 部分:主要包含初始化配置、事件处理、与Flash通信等功能。开发者可以设置各种参数,如文件类型限制、最大上传文件大小、并发上传数量等。同时,JavaScript还负责监听并处理Flash发出的事件,如文件...

    jquery swfupload图片上传插件制作图片批量上传和单...

    - **JavaScript API**:jQuery Swfupload 提供了一系列JavaScript接口,如初始化、开始上传、暂停上传、取消上传等,方便开发者进行控制和定制。 - **事件驱动**:插件基于事件模型,如文件选择、文件上传进度、...

    SWFUpload 批量上传插件

    3. HTML与JavaScript接口:在HTML中添加上传按钮,并通过JavaScript调用SWFUpload实例化对象,设置事件监听器来处理用户交互。 4. 服务器端处理:在服务器端编写接收上传文件的代码,处理上传请求,保存文件,并返回...

    SWFUpload上传插件

    2. 初始化SWFUpload实例,设置上传参数(如URL、文件类型限制等)和回调函数。 3. 将SWFUpload对象绑定到特定的HTML元素,通常是按钮或隐藏的IFrame。 4. 使用SWFUpload提供的方法启动上传,如`startUpload()`和`...

    swfupload插件

    2. **初始化配置**:使用jQuery选择器找到上传按钮元素,然后通过`.swfupload()`方法创建一个SwfUpload实例,并配置相关参数,如服务器端接收文件的URL、文件类型限制等。 3. **绑定事件**:利用jQuery的事件绑定...

    Swfupload插件+css.rar

    使用SwfUpload时,你需要在HTML页面中嵌入Flash对象,并通过JavaScript调用SwfUpload的API进行配置和初始化。例如,设置服务器端接收文件的URL、设置允许上传的文件类型、设置最大上传文件大小等。同时,你还需要...

    flash头像上传组件_swfupload头像上传插件代码

    1. **初始化**:创建SWFUpload实例,设置基本配置和事件监听器。 2. **文件选择**:触发SWFUpload的`uploadStart`事件,开始文件选择。 3. **上传处理**:监听`fileQueued`事件,将文件加入上传队列;`...

    经典上传插件swfupload

    功能完整的上传demo,适用于jsp的应用,兼容性好,配置齐全,带进度条

    web项目使用swfupload插件实现多文件上传

    接下来,编写JavaScript代码初始化SWFUpload实例。在代码中,你需要指定服务器端处理上传的URL、文件类型限制、最大文件大小等参数。以下是一个基本的初始化示例: ```javascript var swfUploadInstance = new ...

    SWFUpload上传插件下载.zip

    - **初始化设置**:调用`SWFUpload.init()`方法,配置上传参数,如URL、文件类型、最大文件大小等。 - **事件监听**:注册事件处理函数,监听上传过程中的各种事件。 - **操作接口**:使用`SWFUpload.startUpload...

    基于SwfUpload插件的文件批量上传插件GooUploader

    本控件是对swfUpload这个FLASH插件的二次包装,控件类对象中的一个内部元素即为一个SWFUpload对象,可对其中进行相应的操作(详见附送的SWFUpload V2_2_0 说明文档.htm) 本控件内置一个保存了文件列表信息的数组$...

    swfUpload 使用简单例子

    3. **初始化SWFUpload**:在JavaScript中调用SWFUpload初始化函数,传入配置参数。 4. **事件绑定**:注册事件处理器,处理用户选择文件、上传开始、上传进度、上传成功或失败等事件。 5. **UI集成**:创建自定义的...

    SwfUpload插件带数据库

    3. 初始化SwfUpload对象,并绑定各种事件处理器,如文件选择、上传开始、上传进度和上传完成等。 4. 实现后端接口,处理文件接收并保存,同时处理数据库操作,确保文件信息准确无误地入库。 在实际应用中,...

    文件上传插件SWFUpload的使用指南

    - **初始化设置**:创建SWFUpload对象,设置一系列配置参数,如上传URL、Flash URL、文件名、POST参数等。 - **选择文件**:用户点击自定义的Flash按钮,选择要上传的文件。 - **文件队列**:符合规定的文件进入...

    Extjs Swfupload 多图上传插件绝对可运行

    总的来说,这个插件结合了Extjs的组件化和Swfupload的上传能力,为Web开发者提供了一个易于集成、功能完善的多图上传解决方案,同时具备进度显示,提升了用户体验。对于需要在网页上实现批量图片上传的开发者来说,...

    swfupload多文件上传组件

    SWFUpload v2包含了新的高级功能,改善了稳定性,解决了FlashPlayer中的一些bug,并且提供一套有用的插件。新的功能包括: * 兼容了Flash Player 10的安全限制问题 * 在文件上传的同时能够发送额外的POST数据 * ...

Global site tag (gtag.js) - Google Analytics