extjs swfupload

极客效率局 极客效率局 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

var uploadFilesWin = new Ext.Window({
title : '多文件上传',
width : 500,
height : 300,
resizable : false,
layout : 'fit',
items : [{
xtype : 'uploadpanel',
uploadUrl : 'uploadpanel',
filePostName : '',
flashUrl : '',
fileSize : '1024*550',
height : 400,
border : false,
fileTypes : '*.*', // 在这里限制文件类型:'*.jpg,*.png,*.gif'
fileTypesDescription : '所有文件',
postParams : {
path : 'files\\' // 上传到服务器的files目录下面
}
}],
bbar : ['xaaaxx'] [code=html]

});
uploadFilesWin.show();[/code]
uploadpanel代码
UploadPanel = Ext.extend(Ext.Panel, {
fileList : null,
swfupload : null,
progressBar : null,
progressInfo : null,
uploadInfoPanel : null,
constructor : function(config) {
//定义 panel1 中的初始信息
this.progressInfo = {
filesTotal : 0,
filesUploaded : 0,
bytesTotal : 0,
bytesUploaded : 0,
currentCompleteBytes : 0,
lastBytes : 0,
lastElapsed : 1,
lastUpdate : null,
timeElapsed : 1
};
//定义panel1,包括他的位置大小等信息
this.uploadInfoPanel = new Ext.Panel({
region : 'north',
height : 65,
baseCls : '',
collapseMode : 'mini',
split : true,
border : false
});
this.progressBar = new Ext.ProgressBar({
text : '等待中 0 %',
animate : true
});
this.uploadInfoPanel.on('render', function() {
this.getProgressTemplate().overwrite(this.uploadInfoPanel.body, {
filesUploaded : 0,
filesTotal : 0,
bytesUploaded : '0 bytes',
bytesTotal : '0 bytes',
timeElapsed : '00:00:00',
timeLeft : '00:00:00',
speedLast : '0 bytes/s',
speedAverage : '0 bytes/s'
});
}, this);
//定义panel2的数据列以及工具条
this.fileList = new Ext.grid.GridPanel({
border : false,
enableColumnMove : false,
enableHdMenu : false,
columns : [new Ext.grid.RowNumberer(), {
header : '文件名',
width : 100,
dataIndex : 'fileName',
sortable : false,
fixed : true,
//renderer : this.formatFileName,
id : autoExpandColumnId
}, {
header : '大小',
width : 80,
dataIndex : 'fileSize',
sortable : false,
fixed : true,
//renderer : this.formatFileSize,
align : 'right'
}, {
header : '类型',
width : 60,
dataIndex : 'fileType',
sortable : false,
fixed : true,
//renderer : this.formatIcon,
align : 'center'
}, {
header : '进度',
width : 100,
dataIndex : '',
sortable : false,
fixed : true,
//renderer : this.formatProgressBar,
align : 'center'
}, {
header : ' ',
width : 28,
dataIndex : 'fileState',
//renderer : this.formatState,
sortable : false,
fixed : true,
align : 'center'
}],
autoExpandColumn : autoExpandColumnId,
ds : new Ext.data.SimpleStore({
fields : ['fileId', 'fileName', 'fileSize', 'fileType', 'fileState']
}),
bbar : [this.progressBar],
tbar : [{
text : '添加文件',
iconCls : 'db-icn-add'
}, {
text : '开始上传',
iconCls : 'db-icn-upload_',
handler : this.startUpload,
scope : this
}, {
text : '停止上传',
iconCls : 'db-icn-stop',
handler : this.stopUpload,
scope : this
}, {
text : '取消队列',
iconCls : 'db-icn-cross',
handler : this.cancelQueue,
scope : this
}, {
text : '清空列表',
iconCls : 'db-icn-trash',
handler : this.clearList,
scope : this
}]
});
}
});
Ext.reg('uploadpanel',UploadPanel);
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
极客效率局
JavaScript 87,983 成员 224,680 内容