如题,上网查了一天没找到解决办法,哪位老大帮帮忙啊
解决方案 »
- JavaSCRIPT有没有能直接从页面的直接抓一个table放excel的方法(我有放word里面的,excel不知道怎么弄)
- js的问题看不明白请大家个解释一下。
- form里面如何获取下拉框的值?
- 正则高手帮帮忙!
- Easyui TreeGrid 全部展开后垂直滚动条不显示
- 刚学JS,代码求解释
- 谁能看懂这个脚本?
- 页面的显示问题,跪求!!!!!!!!!
- 如何保存服务器applet生成的图片?~~~哥哥妹妹们来看看 见者有"份"
- 在英文操作系统中javaScript文件的汉字显示为乱码?怎解?50分!!!!
- jquery-ui-1.8.16.custom 里面的demo在FF 和chrome里面怎么看不到效果?
- JS表单验证IE通过,在Firefox Opera下运行有误!
<head>
<title>fileupload</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<%@ include file="/templates/header/ext.jsp"%>
<script type="text/javascript">
Ext.onReady(function() {
Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';
var form = new Ext.form.FormPanel({
renderTo : 'file',
labelAlign : 'right',
title : 'fileupload',
labelWidth : 70,
frame : true,
url : '../../add_swxx.do?action=save',// fileUploadServlet
width : 380,
height : 200,
fileUpload : true,
items : [{
xtype : 'textfield',
fieldLabel : 'file',
name : 'file',
inputType : 'file'
}, {
xtype : 'textfield',
fieldLabel : 'file1',
name : 'file1',
inputType : 'file'
}, {
xtype : 'textfield',
fieldLabel : 'file2',
name : 'file2',
inputType : 'file'
},{
xtype : "textfield",
fieldLabel : 're',
id : "re",
allowBlank : true,
anchor : "96%"
}], buttons : [{
text : 'upload',
handler : function() {
Ext.MessageBox.show({
title : 'Please wait',
msg : 'Uploading...',
progressText : '',
width : 300,
progress : true,
closable : false,
animEl : 'loding' });
form.getForm().submit({
success : function(form, action) {
Ext.Msg.alert('Tip', action.result.msg);
},
failure : function() {
Ext.Msg.alert('Error', 'fail to upload');
},
waitMsg : 'uploading...' });
}
}]
});});
</script>
</head>
<body>
<DIV id=file>
</body>
</html></DIV>
String saveDirectory = "/home/caterpillar/files/";
// 限制上传之文件大小为 5 MB
int maxPostSize = 5 * 1024 * 1024 ;
MultipartRequest multi = new MultipartRequest(request ,saveDirectory , maxPostSize, "UTF-8");Enumeration filenames = multi.getFileNames();
while(filenames.hasMoreElements()) {
String filename = (String) filenames.nextElement();
out.println("上传了文件" + filename + "<br>");
}
我的前台代码,表单提交部分: function submit() {
// if (!upfile_form.getForm().isValid()) return;
upfile_form.getForm().submit({
waitMsg: '正在提交数据',
waitTitle: '提示',
url:'/upfileExt/servlet/upfileServlet',
// fileUpload:true,
method: 'post',
success: function(re,v) {
var jsonobject = Ext.util.JSON.decode(v.response.responseText);//将返回的JSON数据转换成JSON对象,转换失败即报错.
Ext.Msg.alert("msg,oject",jsonobject.msg);
// Ext.Msg.alert('提示', '保存成功');
},
failure: function(re,v) {
Ext.Msg.alert('提示', '上传失败');
}
});
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//获取各个变量的值
FileUploadPO fup=new FileUploadPO();
//上传文件
SmartUpload upload=new SmartUpload();
//初始化对象
upload.initialize(this.getServletConfig(), request, response);
//限制总上传数据的长度:字节,K,M
upload.setTotalMaxFileSize(1024*1024*50);
try {
Date now = new Date();
upload.initialize(this.getServletConfig(), request, response);
upload.upload();
com.jspsmart.upload.Request rq = upload.getRequest();
String paperTitle = rq.getParameter("paperTitle");//paperTitle对应的前台界面是:{type:textfield,fieldLabel:'文章标题',name:'paperTitle',id:'paperTitle'}