ext 3.x 让uploadPanel支持swfupload
经常做系统的时候会遇到上传组件,特别是大文件的时候总是很郁闷,长时间无响应导致糟糕的用户体验,所以决定采用swfupload来支持文件上传。
大体代码如下。
var upload = {};
upload.UploadPanel = function (cfg) {
this.iconCls = 'add';
this.text = 'upload';
Ext.apply(this, cfg);
this.setting = {
upload_url: this.uploadUrl,
flash_url: this.flashUrl || '../../../../Scripts/Platform/Upload/swfupload.swf',
file_size_limit: this.fileSize || (1024 * 50),
file_post_name: this.filePostName,
file_types: this.fileTypes || "*.*",
file_types_description: "All Files",
file_upload_limit: "5",
//file_queue_limit : "10",
post_params: this.postParams || { savePath: 'upload\\' },
use_query_string: true,
debug: false,
button_cursor: SWFUpload.CURSOR.HAND,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
custom_settings: {
scope_handler: this
},
file_queued_handler: this.filequeuedhandler,
file_queue_error_handler: this.filequeueerrorhandler,
file_dialog_complete_handler: this.filedialogcomplete_handler,
upload_start_handler: this.uploadstarthandler,
upload_progress_handler: this.onUploadProgress,
upload_error_handler: this.uploaderrorhandler,
upload_success_handler: this.onUploadSuccess,
upload_complete_handler: this.uploadcompletehandler,
queue_complete_handler: this.queuecompletehandler
};
upload.UploadPanel.superclass.constructor.call(this, {
listeners: {
'afterrender': function (e) {
var em = e.btnEl.parent('em');
var placeHolderId = Ext.id();
em.setStyle({
position: 'relative',
display: 'block'
});
em.createChild({
tag: 'div',
id: placeHolderId
});
this.swfupload = new SWFUpload(Ext.apply(this.setting, {
button_width: em.getWidth(),
button_height: em.getHeight(),
button_placeholder_id: placeHolderId
}));
this.swfupload.uploadStopped = false;
Ext.get(this.swfupload.movieName).setStyle({
position: 'absolute',
top: 0,
left: -2
});
},
scope: this,
delay: 100
}
});
}
Ext.extend(upload.UploadPanel, Ext.Button, {
filequeuedhandler: function () {
this.startUpload();
},
filequeueerrorhandler: function () {
},
filedialogcomplete_handler: function () {
},
uploadstarthandler: function () {
},
onUploadProgress: function (file, bytesComplete, totalBytes) {
},
uploaderrorhandler: function () {
},
onUploadSuccess: function () {
},
uploadcompletehandler: function () {
},
queuecompletehandler: function () {
}
});
Ext.reg('btnupload', upload.UploadPanel);
于是调用的时候就很easy了。
new Ext.Window({
width: 650,
title: 'UPLOAD',
height: 300,
tbar: [
{ xtype: 'btnupload',
text: '上传',
fileSize: 1024 * 50,
uploadUrl: 'SaveFile',
filePostName: 'file',
fileTypes: '*.jpg;*.gif;*.png;*.jpeg',
postParams: { savePath: 'upload\\' },
onUploadSuccess: function (s, f) {
console.log(f);
},
onUploadProgress: function (file, bytesComplete, totalBytes) {
var percent = Math.ceil((bytesComplete / totalBytes) * 100);
percent = percent == 100 ? 100 : percent;
console.log(percent);
}
}],
items:
[
]
}).show();


这样需要上传的时候就很轻松了。
ext 3.x 让uploadPanel支持swfupload的更多相关文章
- 【翻译】Ext JS 5的平板支持
原文:Ext JS 5 Tablet Support Ext JS已被公认为桌面Web应用程序的领先框架.自从平板开始在全球挑战PC的销售,无论是个人还是企业,电脑横向的应用已经产生急剧的变化.Sen ...
- [转载]ExtJs4 笔记(3) Ext.Ajax 对ajax的支持
作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/) 本篇主要介绍一下ExtJs常用的几个对JS语法的扩展支持,包括Ajax封装,函数事 ...
- ExtJs4 笔记(3) Ext.Ajax 对ajax的支持
本篇主要介绍一下ExtJs常用的几个对JS语法的扩展支持,包括Ajax封装,函数事件操作封装,还有扩展的常用函数等.Ajax服务端交互式操作是提交到.NET MVC.后续服务端交互都采用这一方式实现. ...
- 12. Ext.Ajax 对ajax的支持
转自:http://www.cnblogs.com/lipan/archive/2011/12/09/2272793.html 本篇主要介绍一下ExtJs常用的几个对JS语法的扩展支持,包括Ajax封 ...
- Ext JS - 问答
Ext JS - 问答 在下面你将可以找到关于Ext JS 的最常见问题的答复.如果没有找到您所需的答复,请访问 Ext JS 论坛或者提交一个支持申请. 如果你确信你的问题可以对本页有补充,请让我们 ...
- SWFUpload简介及中文参考手册(share)
SWFUpload SWFUpload 版本 2 概览 (Overview) 入门( Getting Started) js对象 (SWFUpload JavaScript Object) 构造器(C ...
- [转]使用Sencha Ext JS 6打造通用应用程序
原文地址:http://www.uedsc.com/using-sencha-ext-js-6-to-build-universal-apps.html 在Sencha和整个Ext JS团队的支持下, ...
- SWFUpload 2.5.0版 官方说明文档 中文翻译版
原文地址:http://www.cnblogs.com/youring2/archive/2012/07/13/2590010.html#setFileUploadLimit SWFUpload v2 ...
- 【Ext.Net学习笔记】06:Ext.Net GridPanel的用法(GridPanel 折叠/展开行、GridPanel Selection、 可编辑的GridPanel)
GridPanel 折叠/展开行 Ext.Net GridPanel的行支持折叠/展开功能,这个功能个人觉得还说很有用处的,尤其是数据中包含图片等内容的时候. 下面来看看效果: 使用行折叠/展开功能之 ...
随机推荐
- iOS僵尸对象之研究
Zombie Objects对象研究 一.Xcode 关闭ARC project -> Build settings 搜索 Automatic Reference Counting ...
- Leetcode 200 Number of Islands DFS
统计联通区域块的个数,简单dfs,请可以参考DFS框架:Leetcode 130 Surrounded Regions DFS class Solution { public: int m, n; b ...
- Python错误、调试和测试
try: print('try...') r = 10 / int('a') print('result:', r) except ValueError as e: print('ValueError ...
- JSP内置对象总结
前几天学习了javaee中的jsp(Java Server Pages),即java服务器页面,其实就是在html里面写java代码. 一.概述前言 在总结九大对象之前,有必要先搞清楚几个概念:请求, ...
- lamper技能树
- Linux下远程桌面Windows
rdesktop-1.7.0.tar.gz [root@localhost fcitx]# tar rdesktop-1.7.0.tar.gz [root@localhost fcitx]#cd rd ...
- Ruby on Rails框架开发学习
学习地址:http://www.ixueyun.com/lessons/detail-lessonId-685.html 一.课程概述 软件开发在经历了面向过程编程的阶段,现在正大行其道的是敏捷开发, ...
- 三、oracle 体系结构
1.oracle内存由SGA+PGA所构成 2.oracle数据库体系结构数据库的体系结构是指数据库的组成.工作过程与原理,以及数据在数据库中的组织与管理机制. oracle工作原理: 1).在数据库 ...
- HTTP请求报文和HTTP响应报文(转)
原文地址:http://blog.csdn.net/zhangliang_571/article/details/23508953 HTTP报文是面向文本的,报文中的每一个字段都是一些ASCII码串, ...
- mysql中You can’t specify target table for update in FROM clause错误解决方法
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...