ext3的版本里加个上传的框 - Web 开发 / Ajax
代码长了一些,抱歉,其他的地方不用看的,就看我在程序中标注的那部分就好了的
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="cn.tc.ysale.model.sms.*,cn.tc.ysale.model.user.*,cn.tc.ysale.commons.*" %>
<%
User user = SessionHelper.getLoginAttribute(session).getUser();
String chooseTitle = user.getType()==1?"选择供应商":"选择超市用户";
Sms sms = (Sms)request.getAttribute("sms");
String sendid = "";
String title = "";
String content = "";
if(sms!=null)
{
sendid = sms.getUsername();
title = "回复:"+sms.getTitle();
content = sms.getContent();
}
%>
<html>
<head><title>${sessionScope.applicationName}</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/common.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ext/ext-all.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script type="text/javascript">
function onSave(flag,msg)
{
if(flag)
{
goBack();
}
else
{
if(msg)
{
alert(msg);
}
else
{
alert('保存出错');
}
}
}
function goBack()
{
var url = './sms.jspx';
window.location.replace(url);
}
function chooseRel()
{
var url = './sms.jspx?method=chooseuser';
parent.__showDialog('<%=chooseTitle%>',url,800,600);
}
function clearRel()
{
document.all.xrelid.value = "";
}
Ext.onReady(function(){
var bodyWidth = document.body.clientWidth;
var bodyHeight = document.body.clientHeight;
var relid = new Ext.form.DisplayField({
fieldLabel: '收件人',
name: 'relid',
value:'<input id=xrelid name=xrelid type=text value="<%=sendid%>" style=width:90%> <span class=clink onclick=chooseRel()>选择</span> <span class=clink onclick=clearRel()>清除</span>'
});
var title = new Ext.form.TextField({
fieldLabel: '标 题',
name: 'title',
allowBlank:false,
value:'<%=title%>',
anchor:'100%'
});
////////// 问题一:这个部分是我自己加上去的,是不是这个就是建立了一个上传文件的了?
///////////可是我怎么接收不到呢
var pic = new Ext.form.TextField({
fieldLabel: '附 件',
name: 'pic',
inputType: 'file',
anchor:'100%'
});
//---------------------------------------------------
var content = new Ext.form.HtmlEditor({
hideLabel: true,
anchor: '100%',
height: bodyHeight-130,
name: 'content', // 内容的form名,
value: Ext.util.Format.htmlDecode('<%=content%>')
});
function doSave()
{
e.title.value = title.getValue();
e.content.value = content.getValue();
e.user.value = document.all.xrelid.value
e.pic.value = pic.getValue();
alert(pic.getValue()+"|"+e.pic.value);
e.submit();
}
var simple = new Ext.FormPanel({
labelWidth: 55,
frame:true,
title:'发送短消息',
defaults: {width: (bodyWidth-85)},
defaultType: 'textfield',
items: [relid,title,pic,content],
buttons: [{
text: '发送',handler:doSave
},{
text: '返回',handler:goBack
}]
});
var viewport = new Ext.Viewport({
layout:'fit',
items:[simple]
});
});
</script>
</head>
<body>
<form name="e" action="./sms.jspx" method="POST" target="hframe" encType="multipart/form-data">
<input type="hidden" name="method" value="send" />
<input type="hidden" name="title" />
<input type="file" NAME="pic" />
<input type="hidden" name="content" />
<input type="hidden" name="user" />
<iframe name="hframe" src="about:blank" style="display:none"></iframe>
</form>
</body>
</html>
问题一所在的位置,是那么写吗?
就代表了加了一个上传文件的筐了吗?
[解决办法]
- JScript code
var pic= new Ext.ux.form.FileUploadField({ id: 'pic', emptyText: 'Select an image', fieldLabel: 'Photo', name: 'photo-path', buttonText: '', buttonCfg: { iconCls: 'upload-icon' } }