EXT+SWFUpload文件上传Word格式文档下载.docx
《EXT+SWFUpload文件上传Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《EXT+SWFUpload文件上传Word格式文档下载.docx(18页珍藏版)》请在冰豆网上搜索。
![EXT+SWFUpload文件上传Word格式文档下载.docx](https://file1.bdocx.com/fileroot1/2022-11/24/fecc76dc-1cb2-4290-b882-e75f1934bd35/fecc76dc-1cb2-4290-b882-e75f1934bd351.gif)
//我用这个代表传文件,0-代表传图片
newExt.SWFUpload(this.uploadfileConfig);
}else{
tmpuploadwin.show();
}
},
tooltip:
{
title:
插入附件'
text:
在光标所在位置插入附件引用.'
cls:
x-html-editor-tip'
}
}
)
在需要的地方引用:
xtype:
htmleditor'
{upload_url:
处理文件上传后台保存的URL,file_size_limit:
文件大小限制,file_upload_limit:
上传文件数限制,del_datafile_url:
删除已上传文件的URL,del_datafile_params:
前面URL参数如'
task=bulletin_delfile'
post_params:
{传文件时需要传的参数,关键字和值都用引号引起来}},
代码(放EXT-all-debug.js最后):
Ext.SWFUpload=function(config){
Ext.apply(this,config);
varApplication={};
Application.uploadDialog={
upload_win_id:
this.upload_win_id,
upload_type:
this.upload_type,
del_datafile_url:
this.del_datafile_url,
del_datafile_params:
this.del_datafile_params,
SingleUpload:
false,//单个/多个文件上传模式
DeleteFileCount:
0,//删除已上传文件次数,限制小于或等于允许上传的文件数file_upload_limit,防止反复删除上传
UploadSuccessCount:
0,//真正上传到服务器上的文件数
FileMaxId:
//处理业务表的最大记录数
StopUpload:
false,//停止上传标志
progressBarText:
this.progressBarText,
statuBarText:
this.statuBarText,
upload_url:
this.upload_url,
file_size_limit:
this.file_size_limit,
file_types:
this.file_types,
file_types_description:
this.file_types_description,
file_upload_limit:
this.file_upload_limit,
file_queue_limit:
this.file_queue_limit,
button_image_url:
this.button_image_url,
button_placeholder_id:
this.button_placeholder_id,
button_width:
this.button_width,
button_height:
this.button_height,
button_cursor:
this.button_cursor,
button_window_mode:
this.button_window_mode,
flash_url:
this.flash_url,
post_params:
this.post_params,
custom_settings:
this.custom_settings,
debug:
this.debug,
show:
function(){
if(!
this.dialog)this.initDialog();
this.uploadAction[1].disable();
this.uploadAction[2].disable();
this.uploadAction[3].disable();
this.uploadAction[4].disable();
this.uploadAction[5].disable();
this.uploadAction[6].disable();
this.uploadAction[7].enable();
},
ok:
varrtnurl='
varobj=Application.uploadDialog;
varstore=obj.uploadGrid.store;
varrowcount=store.getCount();
varfileexticon={'
doc'
:
word'
dot'
rtf'
xls'
excel'
xlt'
xla'
xlw'
pdf'
dll'
'
ppt'
pot'
pps'
ppa'
vsd'
visio'
vss'
vst'
rar'
zip'
swf'
flash'
htm'
html'
mht'
mhtml'
txt'
text'
log'
sql'
exe'
com'
bat'
bmp'
picture'
jpg'
jif'
jfif'
jpeg'
gif'
png'
emf'
ini'
cfg'
rle'
wmf'
dib'
mid'
sound'
midi'
mp3'
asf'
rm'
};
for(vari=0;
i<
rowcount;
i++){
varrec=store.getAt(i);
if(rec.data['
uploaded'
]==1){
varfiletype=rec.data['
filetype'
].toLowerCase();
filetype=(fileexticon[filetype])?
fileexticon[filetype]:
unknow'
//rtnurl=rtnurl+'
<
pstyle="
height:
24px;
font-size:
14px;
line-height:
23px;
"
>
imgsrc="
/resources/00/image/'
+filetype+'
.gif"
border="
0"
aclass="
bulletin"
href="
/bulletin/bulletin_readfile.html?
file='
+rec.data['
]+rec.data['
]+'
.'
linkname'
&
#160;
spanstyle="
font-size:
12px"
['
+Ext.util.Format.fileSize(rec.data['
size'
])+'
]<
/span>
/a>
/p>
rtnurl=rtnurl+'
javascript:
void(0);
onclick="
fun_filedown(\'
name='
+encodeURIComponent(rec.data['
path='
\'
)"
}
this.dialog.hide();
Ext.getCmp(this.dialog.id.substr(0,this.dialog.id.length-10)).insertAtCursor(rtnurl);
hide:
deletefile:
function(rec,store,obj){
if(rec.data.uploaded=='
1'
){//删除上传成功的文件,需要删除数据库信息和服务器文件
if(obj.DeleteFileCount>
=obj.file_upload_limit){
msgbox('
E'
已达到上传文件删除次数限制!
returnfalse;
vardeltmpparams=obj.del_datafile_params+'
filepath='
+rec.data.linkurl+'
filename='
+rec.data.servername+'
fileext='
+rec.data.filetype;
vardelinfo=fun_sync_exec(obj.del_datafile_url,deltmpparams);
delinfo=Ext.decode(delinfo);
if(delinfo.state==false){//后台删除失败
rec.set('
4'
errinfo'
delinfo.info);
mitChanges();
}else{//后台删除成功
obj.DeleteFileCount++;
//增加删除次数
obj.UploadSuccessCount--;
//减少真正上传数
obj.swfu.setStats({successful_uploads:
obj.UploadSuccessCount});
//减少SWF真正上传数
obj.swfu.cancelUpload(rec.data.id,false);
store.remove(rec);
}else{//删除未上传或未成功的文件
obj.swfu.cancelUpload(rec.data.id,false);
store.remove(rec);
obj.stateInfo.getEl().innerHTML=String.format(obj.statuBarText,store.getCount(),Ext.util.Format.fileSize(store.sum('
)));
if(store.getCount()==0){
store.removeAll();
obj.uploadProgressBar.updateProgress(0,'
obj.uploadProgressBar.updateText('
obj.swfu.setButtonDisabled(false);
obj.uploadAction[1].disable();
obj.uploadAction[2].disable();
obj.uploadAction[3].disable();
obj.uploadAction[4].disable();
obj.uploadAction[5].disable();
obj.uploadAction[6].disable();
returntrue;
uploadAction:
[
newExt.Action({id:
fileupload_selectfile_id'
}),
newExt.Action({text:
删除选择'
iconCls:
filedel'
disabled:
true,handler:
varobj=Application.uploadDialog;
vargrid=obj.uploadGrid;
if(!
grid.selModel.hasSelection()){
W'
请先选择要删除的记录!
return;
varstore=grid.store;
varselection=grid.getSelectionModel().getSelections();
for(vari=0;
selection.length;
varrec=store.getAt(store.indexOfId(selection[i].id));
if(!
obj.deletefile(rec,store,obj))returnfalse;
//删除
}}),
清空全部'
filecancel'
varstore=obj.uploadGrid.store;
varlen=store.getCount();
len;
varrec=store.getAt(0);
上传选择'
fileupselect'
obj.SingleUpload=true;
//单个上传模式
请先选择要上传的记录!
varrec=selection[0];
obj.swfu.startUpload(rec.data.id);
上传全部'
fileupall'
obj.SingleUpload=false;
//多个上传模式
obj.StopUpload=false;
//取消停止标志
obj.swfu.startUpload();
停止进程'
fileupstop'
obj.StopUpload=true;
//设置停止标志
obj.swfu.stopUpload();
确定'
ok'
handler:
Application.uploadDialog.ok();
退出'
exit'
Application.uploadDialog.hide();
}})
],
initDialog:
this.dialog=newExt.Window({id:
this.upload_win_id,iconCls:
animCollapse:
false,
layout:
fit'
width:
640,height:
370,title:
附件上传...'
closeAction:
hide'
border:
modal:
true,plain:
true,closable:
false,resizable:
true,collapsible:
true,maximizable:
true,
bbar:
[this.uploadProgressBar=newExt.ProgressBar({width:
624})],
items:
this.uploadGrid=newExt.grid.EditorGridPanel({
autoExpandColumn0:
1,enableHdMenu:
false,clicksToEdit:
1,autoEncode:
true,selModel:
newExt.grid.RowSelectionModel({singleSelect:
true}),
tbar:
[this.uploadAction[0],'
this.uploadAction[1],this.uploadAction[2],
'
this.uploadAction[3],this.uploadAction[4],'
this.uploadAction[5],'
->
this.uploadAction[6],'
this.uploadAction[7]],
bbar:
[this.stateInfo=newExt.Toolbar.TextItem(String.format(this.statuBarText,0,Ext.util.Format.fileSize(0)))],
store:
newExt.data.SimpleStore({fields:
['
autoid'
id'
'
file'
reuploadcount'
],data:
[]}),
columns:
newExt.grid.RowNumberer1(),
{header:
文件名称'
200,dataIndex:
sortable:
true},
大小'
width:
60,renderer:
Ext.util.Format.fileSize,dataIndex:
true,align:
right'
},
状态'
70,dataIndex:
align:
center'
true,renderer:
function(_value){if(_valu