標籤:
(function($){ var methods = { init:function(options){ return this.each(function(){ var $this = $(this); var $clone = $this.clone(); var settings = $.extend({ id : $this.attr(‘id‘), button:$this, uploader : ‘‘, formData:{}, auto : true, fileTypes : ‘*.*‘, multi : true, fileSizeLimit: 0, queueSizeLimit:1, onUploadStart:function(fileManager){return true;},//上傳開始時的動作 onUploadSuccess:function(fileManager, response){},//上傳成功的動作 onUploadComplete:function(fileManager){},//上傳完成的動作 onUploadError:function(fileManager, response){},//上傳失敗的動作 onProgress:function(fileManager, loaded, total){},//上傳進度 onInit:function(){},//初始化時的動作 //beforeUpload:function(){}, //開始上傳前執行 },options); this._uploader = new H5Uploader.Uploader(settings); }); } }; $.fn.html5uploader = function(method){ if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === ‘object‘ || !method) { return methods.init.apply(this, arguments); } else { $.error(‘The method ‘ + method + ‘ does not exist in $.html5uploader‘); } }; })(jQuery);
完整指令碼(提取碼:a088)
基於jQuery仿uploadify的HTML5圖片上傳控制項jquery.html5uploader