封装 jquery,artDialog,swfupload 的上传插件
//document.write("<script language=\"javascript\" src='..\/js\/j.js' > <\/script>"); var SRM_SWFUpload = SRM_SWFUpload || {}; SRM_SWFUpload.SPLITE = ':'; SRM_SWFUpload.ART_DIALOG_VER = art.dialog.fn.version; (function($){ $.fn.swfuInit= function(settings){ //默认参数 var defaultSettings = { // 附件ID,submit to server appendixId:'appendixId', // 附件源文件名, uploadFileName:'uploadFileName', // 附件重命名后 文件名 oldPath:'oldPath', // 上传文件时 的临时路径 picturePath:'picturePath', // 上传文件的大小 单位:字节 pictureSize:'pictureSize', // 附件ID,submit to server appendixIdVal:'', // 附件源文件名, uploadFileNameVal:'', // 附件重命名后 文件名 oldPathVal:'', // 上传文件时 的临时路径 picturePathVal:'', // 上传文件的大小 单位:字节 pictureSizeVal:'', // 上传按钮后的描述信息 descInfo:'点击此按钮可上传小于100M的附件', // 文件的存放路径 filePath : '', // 是否多选 multiple:true, // 提交文件域的参数名称 filePostName:'uploadFile', // 允许上传文件的类型,以 ; 分割,*.jpg;*.doc fileTyps:'*.*', fileTypesDesc : 'All File', // 默认单位是KB fileSizeLimit : "100 MB", fileUploadLimit : 1000, fileQueueLimit : 0, postParams : {}, downFile:function (url, filePath) { // 下载temp文件 if (!filePath || filePath == '') { if (url && url.indexOf(SRM_SWFUpload.SPLITE) >= 0) { var urlArr = url.split(SRM_SWFUpload.SPLITE); for(var i = 0;i < urlArr.length; i++){ window.open("../upload/download.action?fileUrl=" + urlArr[i]); } } else { window.open("../upload/download.action?fileUrl=" + url); } } else { if (url && url.indexOf(SRM_SWFUpload.SPLITE) >= 0) { var urlArr = url.split(SRM_SWFUpload.SPLITE); for(var i = 0;i < urlArr.length; i++){ window.open("../upload/download.action?fileUrl=" + urlArr[i] +"&filePath=" + filePath) } } else { window.open("../upload/download.action?fileUrl=" + url +"&filePath=" + filePath) } } }, showTip : false, showPercent : false }; /* 合并默认参数和用户自定义参数 */ settings = $.extend(defaultSettings, settings); var _swfu ; this.each(function(){ // 方法体 var elem = $(this); if (!elem) { return ; } _swfu = new SRMSWFU(elem, settings); _swfu.generate(); }); return _swfu; }; /* * 私有函数 */ function SRMSWFU(elem, settings) { this.settings = settings; // 下载文件的保存路径 this.filePath = settings.filePath, this.uploadDiv = elem; this.prefixName = elem.attr("id"); this.prefixIndex = SRM_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; }; SRMSWFU.prototype = { generate : function() { var self = this; // 初始化调用SWFUpload对象初始化 if (self.uploadDiv) { self.uploadDiv.html(""); } var htmls = self.generateHTML(self.uploadDiv); var upObjId = self.prefixName; 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: "../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 : function (numFilesSelected, numFilesQueued){ if (numFilesSelected > 0 && numFilesQueued > 0) { var dialog = art.dialog.confirm("确认要上传已选的 "+numFilesQueued+" 个文件吗?",function(){ try { self.selectFileCount = numFilesQueued; self.swfuObject.startUpload(); } catch (ex) { dialog.close(); } },function(){ // 取消了队列 self.swfuObject.cancelQueue(); }); } }, // 选中文件后确定后执行 file_queued_handler : function (file) { // 当文件选择对话框关闭消失时,如果选择的文件成功加入上传队列,那么针对每个成功加入的文件都会触发一次该事件(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.id); self.SWF_SELECT_FILE_NAME = self.SWF_SELECT_FILE_NAME + file.name + SRM_SWFUpload.SPLITE ; }, 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 + " 过大,请选择"+this.settings.file_size_limit+"以内的文件进行上传."); //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("请选择大于0KB,小于"+this.settings.file_size_limit+"的文件进行上传."); //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_start_handler : function (file) { 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 (!SRM_SWFUpload.uploadTip) { SRM_SWFUpload.uploadTip = //art.dialog.tips('正在上传文件 '+file.name+' ,请稍等...', 60); self.uploadTips('正在上传文件 '+file.name+' ,请稍等...'); } else { SRM_SWFUpload.uploadTip.content('正在上传文件 '+file.name+' ,请稍等...').title('上传中...').show(); } } } catch (ex) { } return true; }, // 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); break; case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: progress.setStatus("Upload Failed."); this.debug("文件 " + file.name + " 尺寸过大. " + file.size + ", 请重新选择."+message); break; case SWFUpload.UPLOAD_ERROR.IO_ERROR: progress.setStatus("Server (IO) Error"); art.dialog.alert("Error Code: IO Error, File name: " + file.name + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: progress.setStatus("Security Error"); art.dialog.alert("Error Code: Security Error, File name: " + file.name + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: progress.setStatus("Upload limit exceeded."); art.dialog.alert("文件队列已满,文件 " + file.name + " 上传失败. " + message); break; case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: progress.setStatus("Failed Validation. Upload skipped."); art.dialog.alert("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", 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: " + file.size + ", Message: " + message); break; } }, upload_success_handler : function (file, serverData) { /* * 注意不能 * this.cancelUpload(); * 不然导致 * 一个上传完成(发送file信息,并返回200状态时调用此方法)后, * 取消只会取消当前文件的上传,而不是取消整个队列上传,所以每隔一个就会被取消 * 这个upload_success_handler每个文件上传完成都会调用一次,一个文件上传周期没有完成,还会触发upload_complete_handler;uploadComplete(file) * */ if (serverData != null && serverData != ""){ try { file.id = "singlefile"; var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setComplete(); progress.setStatus("Complete."); progress.toggleCancel(false); debugger; var _uploadFileName = $("#"+self.contextName+self.settings.uploadFileName); var _picturePath = $("#"+self.contextName+self.settings.picturePath); var _pictureSize = $("#"+self.contextName+self.settings.pictureSize); _uploadFileName.val(self.SWF_SELECT_FILE_NAME); if(self.settings.multiple) { var _picturePathVal = _picturePath.val().indexOf(SRM_SWFUpload.SPLITE) <= 0 ? _picturePath.val() + SRM_SWFUpload.SPLITE : _picturePath.val(); if (_picturePathVal != "") { _picturePath.val(_picturePathVal + serverData + SRM_SWFUpload.SPLITE); } else { _picturePath.val(_picturePath.val() + serverData + SRM_SWFUpload.SPLITE); } _pictureSize.val(_pictureSize.val() + file.size + SRM_SWFUpload.SPLITE); } else { _picturePath.val(serverData); _pictureSize.val(file.size); } // 全部上传完成后显示文件名称 // var _biddingFileId = $("#"+self.biddingFileId); // _biddingFileId.append(file.name + SRM_SWFUpload.SPLITE); if (self.settings.showPercent) { /* * 计算上传进度,总数量selectFileCount */ var percent = Math.ceil(((self.selectFileCount - this.getStats().files_queued) / self.selectFileCount) * 100); if (!SRM_SWFUpload.uploadTip) { //art.dialog.tips('正在上传文件 '+file.name+' ,请稍等...', 60); SRM_SWFUpload.uploadTip = self.uploadTips(percent+' %'); } else { SRM_SWFUpload.uploadTip.content(percent+' %').show(); } } } catch (e) { alert("upload_success_handler"+e); } } }, upload_complete_handler : function (file) { //("上传完成");,不一定是上传成功 if (this.getStats().files_queued === 0) { // 队列文件全部上传完成 document.getElementById(this.customSettings.cancelButtonId).disabled = true; var _uploadFileName = $("#"+self.contextName+self.settings.uploadFileName); _uploadFileName.val(self.getLastSplitStr(_uploadFileName.val(), SRM_SWFUpload.SPLITE)); var _picturePath = $("#"+self.contextName+self.settings.picturePath); _picturePath.val(self.getLastSplitStr(_picturePath.val(), SRM_SWFUpload.SPLITE)); var _pictureSize = $("#"+self.contextName+self.settings.pictureSize); _pictureSize.val(self.getLastSplitStr(_pictureSize.val(), SRM_SWFUpload.SPLITE)); var _biddingFileId = $("#"+self.biddingFileId); _biddingFileId.html(self.getLastSplitStr(self.SWF_SELECT_FILE_NAME, SRM_SWFUpload.SPLITE).split(SRM_SWFUpload.SPLITE).join('<br/>')); $("#"+self.delFileButtonId).html("删除"); self.SWF_SELECT_FILE_NAME = ''; // 判断队列没有文件,关闭上传tip if (self.settings.showTip || self.settings.showPercent) { if (SRM_SWFUpload.uploadTip){ //SRM_SWFUpload.uploadTip.content('上传完成.'); SRM_SWFUpload.uploadTip.title('完成'); SRM_SWFUpload.uploadTip.hide(); // SRM_SWFUpload.uploadTip.button( // { // name: '确定', // callback: function () { // this.hide(); // }, // disabled: false // } // ) //self.uploadCompleteTip('上传完成.'); } } } }, swfupload_loaded_handler: function () { // ready } }; this.swfuObject = new SWFUpload(_swfSet); this.addToList(this.prefixName, this.swfuObject); }, generateHTML : function (divObj){ var self = this; var delFileButtonHtml = '<a style="padding-left:10px;" href="javascript:void(0);" id="'+this.delFileButtonId+'"></a> '; if (this.settings.uploadFileNameVal != "") { delFileButtonHtml = '<a style="padding-left:10px;" href="javascript:void(0);" id="'+this.delFileButtonId+'">删除</a> '; } var divHtml = [ // fsUploadProgress '<div style="display:none;" id="'+this.progressTarget+'" ></div>', '<div style="display:none;" id="'+this.divStatusId+'divStatus" ></div>', '<div style="height:28px;">', '<div style="float:left;padding-top:5px">', '<a href="javascript:void(0);">', '<span id="'+this.biddingFileId+'">'+this.settings.uploadFileNameVal+'</span>', '</a>', delFileButtonHtml, '</div>', '<div style="" id="'+this.buttonId+'"></div>', '<input id="'+this.cancelButtonId+'" type="button" value="Cancel All Uploads" disabled="disabled" style="display:none;"/>', '<span id="'+this.prefixName+'desc">'+this.settings.descInfo+'</span>', // 五个隐藏域 '<input name="'+this.settings.appendixId+'" id="'+this.contextName+this.settings.appendixId+'" type="hidden" value="'+this.settings.appendixIdVal+'"/>', '<input name="'+this.settings.uploadFileName+'" id="'+this.contextName+this.settings.uploadFileName+'" type="hidden" value="'+this.settings.uploadFileNameVal+'"/>', '<input name="'+this.settings.oldPath+'" id="'+this.contextName+this.settings.oldPath+'" type="hidden" value="'+this.settings.oldPathVal+'"/>', '<input name="'+this.settings.picturePath+'" id="'+this.contextName+this.settings.picturePath+'" type="hidden" value="'+this.settings.picturePathVal+'"/>', '<input name="'+this.settings.pictureSize+'" id="'+this.contextName+this.settings.pictureSize+'" type="hidden" value="'+this.settings.pictureSizeVal+'"/>', '<input name="multiple" id="'+this.contextName+'multiple" value="'+this.settings.multiple+'" type="hidden"/>', '</div>', ''].join(""); divObj.html(divHtml); $("#"+self.biddingFileId).parent().click( function () { self.downFile('downFile'); }); $("#"+self.delFileButtonId).click( function () { self.delFile('del_file'); }); return divHtml; }, downFile:function (handleName) { var fp = this.filePath; this.queueEvent(handleName, [$("#"+this.contextName+this.settings.picturePath).val() ,fp]); }, delFile:function (handleName, id) { // this.queueEvent(handleName, id); var picturePath = $("#"+this.contextName+this.settings.picturePath).val(); // del临时文件 $("#"+this.biddingFileId).html(""); $("#"+this.contextName+this.settings.uploadFileName).val(""); $("#"+this.contextName+this.settings.picturePath).val(""); $("#"+this.contextName+this.settings.pictureSize).val(""); $("#"+this.biddingFileId).html(""); $("#"+this.delFileButtonId).html(""); // 删除临时路径的文件 $.ajax({ url:'../upload/delTempFile.action', type : "POST", data:{'fileUrl':picturePath}, timeout : 120000, cache : false, success:function (data) { try { //var json = $.parseJSON(data); } catch (e) { } }, error:function(){ } }); }, 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) { // 属性名 = 属性值 return SRM_SWFUpload.uploadList[swfuName] = swfuObj; }, getSwfu:function (swfId) { return this.swfuObject; }, getAppendixId:function () { return $("#"+this.contextName+this.settings.appendixId).val(); }, getUploadFileName:function () { return $("#"+this.contextName+this.settings.uploadFileName).val(); }, getPicturePath:function () { return $("#"+this.contextName+this.settings.picturePath).val(); }, getPictureSize:function () { return $("#"+this.contextName+this.settings.pictureSize).val(); }, destroy : function() { this.swfuObject.destroy(); }, cancle : function() { this.swfuObject.cancelQueue(); }, uploadTips :function (content, title) { return art.dialog({ title:title?title:'', minWidth:200, content: content, fixed: true, resize: false, drag: true , yesFn:false, noFn:false, esc:false // , // button: [ // { // name: '确定', // disabled: true // } // ] }); }, 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)); } }; SRM_SWFUpload.movieCount = 0; SRM_SWFUpload.version = "1.1.0 2013-12-05"; SRM_SWFUpload.uploadList = {}; SRM_SWFUpload.uploadTip ; SRM_SWFUpload.add = function(n, o){ return SRM_SWFUpload.uploadList[n] = o; }; SRM_SWFUpload.get = function (id) { return SRM_SWFUpload.uploadList[id]; }; SRM_SWFUpload.destroy = function(id) { if (!id || id == undefined || id == null || id == "") { for(var o in SRM_SWFUpload.uploadList){ SRM_SWFUpload.uploadList[o].destroy(); if (document.getElementById(o)) { document.getElementById(o).innerHTML = ''; } } } else { SRM_SWFUpload.uploadList[id].destroy(); if (document.getElementById(id)) { document.getElementById(id).innerHTML = ''; } } }; })(jQuery);
其他代码参考 1.1版本
相关推荐
1. `index.php`:这是前端展示页面,其中包含了Swfupload插件的初始化代码和HTML结构。通过引入`swfupload`文件,`index.php`页面能够加载并显示上传按钮。Swfupload插件通常会嵌入到一个或多个`<div>`元素中,用户...
SWFUpload是一款经典的JavaScript与Flash结合的文件上传插件,尤其适用于处理图片上传。它允许用户在网页上实现批量和单个图片的上传功能,提高了用户体验,并且在处理大量文件时,比传统的表单提交方式更为高效。...
* 可以同时上传多个文件; * 类似AJAX的无刷新上传; * 可以显示上传进度; * 良好的浏览器兼容性; * 兼容其他JavaScript库 (例如:jQuery, Prototype等); * 支持Flash 8和Flash 9;
1. JavaScript 部分:主要包含初始化配置、事件处理、与Flash通信等功能。开发者可以设置各种参数,如文件类型限制、最大上传文件大小、并发上传数量等。同时,JavaScript还负责监听并处理Flash发出的事件,如文件...
- **JavaScript API**:jQuery Swfupload 提供了一系列JavaScript接口,如初始化、开始上传、暂停上传、取消上传等,方便开发者进行控制和定制。 - **事件驱动**:插件基于事件模型,如文件选择、文件上传进度、...
3. HTML与JavaScript接口:在HTML中添加上传按钮,并通过JavaScript调用SWFUpload实例化对象,设置事件监听器来处理用户交互。 4. 服务器端处理:在服务器端编写接收上传文件的代码,处理上传请求,保存文件,并返回...
2. 初始化SWFUpload实例,设置上传参数(如URL、文件类型限制等)和回调函数。 3. 将SWFUpload对象绑定到特定的HTML元素,通常是按钮或隐藏的IFrame。 4. 使用SWFUpload提供的方法启动上传,如`startUpload()`和`...
2. **初始化配置**:使用jQuery选择器找到上传按钮元素,然后通过`.swfupload()`方法创建一个SwfUpload实例,并配置相关参数,如服务器端接收文件的URL、文件类型限制等。 3. **绑定事件**:利用jQuery的事件绑定...
使用SwfUpload时,你需要在HTML页面中嵌入Flash对象,并通过JavaScript调用SwfUpload的API进行配置和初始化。例如,设置服务器端接收文件的URL、设置允许上传的文件类型、设置最大上传文件大小等。同时,你还需要...
1. **初始化**:创建SWFUpload实例,设置基本配置和事件监听器。 2. **文件选择**:触发SWFUpload的`uploadStart`事件,开始文件选择。 3. **上传处理**:监听`fileQueued`事件,将文件加入上传队列;`...
功能完整的上传demo,适用于jsp的应用,兼容性好,配置齐全,带进度条
接下来,编写JavaScript代码初始化SWFUpload实例。在代码中,你需要指定服务器端处理上传的URL、文件类型限制、最大文件大小等参数。以下是一个基本的初始化示例: ```javascript var swfUploadInstance = new ...
- **初始化设置**:调用`SWFUpload.init()`方法,配置上传参数,如URL、文件类型、最大文件大小等。 - **事件监听**:注册事件处理函数,监听上传过程中的各种事件。 - **操作接口**:使用`SWFUpload.startUpload...
本控件是对swfUpload这个FLASH插件的二次包装,控件类对象中的一个内部元素即为一个SWFUpload对象,可对其中进行相应的操作(详见附送的SWFUpload V2_2_0 说明文档.htm) 本控件内置一个保存了文件列表信息的数组$...
3. **初始化SWFUpload**:在JavaScript中调用SWFUpload初始化函数,传入配置参数。 4. **事件绑定**:注册事件处理器,处理用户选择文件、上传开始、上传进度、上传成功或失败等事件。 5. **UI集成**:创建自定义的...
3. 初始化SwfUpload对象,并绑定各种事件处理器,如文件选择、上传开始、上传进度和上传完成等。 4. 实现后端接口,处理文件接收并保存,同时处理数据库操作,确保文件信息准确无误地入库。 在实际应用中,...
- **初始化设置**:创建SWFUpload对象,设置一系列配置参数,如上传URL、Flash URL、文件名、POST参数等。 - **选择文件**:用户点击自定义的Flash按钮,选择要上传的文件。 - **文件队列**:符合规定的文件进入...
总的来说,这个插件结合了Extjs的组件化和Swfupload的上传能力,为Web开发者提供了一个易于集成、功能完善的多图上传解决方案,同时具备进度显示,提升了用户体验。对于需要在网页上实现批量图片上传的开发者来说,...
SWFUpload v2包含了新的高级功能,改善了稳定性,解决了FlashPlayer中的一些bug,并且提供一套有用的插件。新的功能包括: * 兼容了Flash Player 10的安全限制问题 * 在文件上传的同时能够发送额外的POST数据 * ...