if (this.timeout > 0) { this._timer = setTimeout($$F.bind(this._timeout, this),this.timeout * 1000); } // 开始上传 this._form.submit(); this._sending = true; }, // 停止上传 stop : function() { if (this._sending) { // 停止iframe被加载完成 if (this._iframe) this._iframe.src = "about:blank"; // 取消超时警告 if (this._timer) clearTimeout(this._timer); // 调用onStop事件 this.onStop(); // 取消返回的onFinish函数 if (this._fFINISH) this._fFINISH({state : -1}); } // 取消loading this._loaded(); // 清空iframe,form和表单控件 this._iframe = null; this._form = null; this._inputs = {}; // 清空上传文件对象 this.file.value = ""; this._sending = false; }, // 设置onReady事件 onReady : function() { this.options.onReady.call(this); }, // 设置onFinish事件 onFinish : function() { this.options.onFinish.call(this); }, // 设置onStop事件 onStop : function() { this.options.onStop.call(this); }, // 设置onTimeout事件 onTimeout : function() { this.options.onTimeout.call(this); }, // 设置iframe _setIframe : function() { this._iframe = $$.create("iframe"); this._iframe.id = "quickUpload-iframe-" + QuickUpload._counter++; this._iframe.name = this._iframe.id; this._iframe.style.display = "none"; document.body.appendChild(this._iframe); }, // 设置form _setForm : function() { this._form = $$.create("form"); this._form.method = "post"; this._form.enctype = "multipart/form-data"; this._form.target = this._iframe.id; this._form.action = this.action; this._form.style.display = "none"; document.body.appendChild(this._form); }, // 绑定form _bindForm : function() { this._form.target = this._iframe.id; this._form.action = this.action; }, // 设置input _setInput : function() { // 清空input对象 this._inputs = {}; // 设置参数 for ( var p in this.parameter) { this._inputs[p] = $$.create("input"); this._inputs[p].type = "hidden"; this._inputs[p].name = p; this._inputs[p].value = this.parameter[p]; this._form.appendChild(this._inputs[p]); } }, // 超时函&#x6570 _timeout : function() { if (this._sending) { this.stop(); this.onTimeout(); } // 取消loading this._loaded(); } }

var QuickUpload = functionfile options 		thisfile = $$file;		this_sending = false; 是否正在上传	this_timer = null; 定时器	this_iframe = null; ifra

原文地址: https://www.cveoy.top/t/topic/hXrA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录