ExtJs 上传HTML文件 自己写啊

qq_28388325 2016-03-15 05:03:22




//*****************************************上传的公共js***************************************************************//

/**

* 约定:types为调用时传来的参数.形式为jsp-gig-png

* uploadid为上传后要填充路径的控件id

* 上传的属性均为upload

* 功能:页面调用openUpload("","");方法即可

*/

//...允许上传的后缀名

var types = "";


//...上传后填充控件的id

var uploadid = "";


function openUpload(type, id) {

types = type;

uploadid = id;

winUpload.show();

}


var formUpload = new Ext.form.FormPanel({

baseCls: 'x-plain',

labelWidth: 80,

fileUpload: true,

defaultType: 'textfield',

items: [
{
xtype: 'textfield',
fieldLabel: '服务端文件',
name: 'servername',
allowBlank: false,
value: '',
blankText: '请输入服务端文件名'
},
{

xtype: 'fileuploadfield',

fieldLabel: '本地文件',

buttonText: '浏览',

name: 'upload',

allowBlank: false,

blankText: '请上传本地文件',

anchor: '90%' // anchor width by percentage

}
]

});


var winUpload = new Ext.Window({

title: '资源上传',

width: 400,

height: 200,

minWidth: 300,

minHeight: 100,

layout: 'fit',

plain: true,

bodyStyle: 'padding:5px;',

buttonAlign: 'center',

items: formUpload,

buttons: [{

text: '上 传',

handler: function () {

if (formUpload.form.isValid()) {

Ext.MessageBox.show({

title: '请等待',

msg: '正在上传...',

progressText: '',

width: 300,

progress: true,

closable: false,

animEl: 'loading'

});

formUpload.getForm().submit({

url: 'uploadFileAction.action',

success: function (form, action) {

var objxzdz = Ext.get(uploadid).dom;

objxzdz.value = action.result.msg;

Ext.Msg.alert('成功', '上传成功.');

winUpload.hide();

},

failure: function (form, action) {

//... action生成的json{msg:上传失败},页面就可以用action.result.msg得到非常之灵活

Ext.Msg.alert('Error', action.result.msg);

}

})

}

}

}, {

text: '取 消',

handler: function () {
winUpload.hide();
}

}]

});

//*****************************************上传的公共js***************************************************************//



package com.huateng.business.common.action;

import com.huateng.business.wx.common.utils.FileUploadUtil;
import com.huateng.web.action.DefaultPageSupportAction;
import net.sf.json.JSONObject;

import java.io.File;


/**
* 上传的公共方法
*
* @author sam.zhang
*/

public class UploadFileAction extends DefaultPageSupportAction {


/**

*

*/

private static final long serialVersionUID = 1L;


//和前台的名字一样,这里约定是 upload
private File upload;
private String servername;

private String fileName;
private String uploadContentType;


public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

public String getUploadContentType() {
return uploadContentType;
}

public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}


public String getServername() {
return servername;
}

public void setServername(String servername) {
this.servername = servername;
}

public File getUpload() {

return upload;

}


public void setUpload(File upload) {

this.upload = upload;

}

public String execute() throws Exception {
JSONObject jsonObject = new JSONObject();
servername = servername.trim();
//文件名不包括斜杠
if (servername.contains("/")) {
jsonObject.put("failure", "true");
jsonObject.put("msg", "文件名不能包括目录");
return SUCCESS;
}


FileUploadUtil fileUploadUtil = new FileUploadUtil();
if (!fileUploadUtil.saveFile(this.getUpload(),
fileUploadUtil.getTmpDir() + getServername())) {
jsonObject.put("failure", "true");
jsonObject.put("msg", fileUploadUtil.getResultMsg());
} else {
jsonObject.put("success", "true");
jsonObject.put("msg", getServername());
}
setResData(jsonObject.toString());
return SUCCESS;
}
}

能把那个HTML文件 自己写么 不用上传 求大神
...全文
246 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_28388325 2016-04-07
  • 打赏
  • 举报
回复
就是在增加一个 HTML编辑器 能自己编辑文件HTML文件
  • 打赏
  • 举报
回复
不懂要问什么。。上传不用ext的file组件,加载自己的html页面?那不是设置window的html为iframe的html加载你的页面
var winUpload = new Ext.Window({

    title: '资源上传',

    width: 400,

    height: 200,

    minWidth: 300,

    minHeight: 100,

    layout: 'fit',

    plain: true,

    bodyStyle: 'padding:5px;',

    buttonAlign: 'center',
html:'<iframe src="xxxxxxxxxxx" width="100%" height="150"></iframe>'
    //items: formUpload,

52,778

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧