基於jQuery仿uploadify的HTML5圖片上傳控件jquery.html5uploader


(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);

 

完整腳本 (提取碼:7261)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM