struts上传 急 急 急 哪位大侠有像 邮箱上传附件 一样 jsp+java的上传代码 (附件不定数)小弟高分 求 邮箱 [email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 真巧,我们刚用strtus1.2写了个上传包含检查文件格式、文件大小等功能很好用 推荐使用sturts2,只要配置几个标签就OK了 赞成ajax 也行下开源代码 插件都可以办到 ^_* 在ActionForm 声明变量 //上传的文件名 private FormFile fileName; public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //获取从页面表单中提交过来的值 UploadActionForm iaf = (UploadActionForm )form; FormFile myFile = iaf.getFileName(); if(myFile != null){ //将上传的文件流保存到磁images/item下 //String realPath = request.getContextPath().getRealPath("/images/upload"); //System.out.println("realpath" + ); //FileOutputStream fos = new FileOutputStream("C:\\upload\\"+iaf.getUploadName() + ".gif"); FileOutputStream fos = new FileOutputStream("C:\\upload\\"+iaf.getUploadName()+ ".gif"); fos.write(myFile.getFileData()); fos.flush(); fos.close(); } return mapping.findForward("success") 我们系统是 不允许我用 struts2 啊 struts2---页面导向问题 讨论题 求高手帮忙,JSP中怎样获取文本框内的文件路径及文件名! Struts2效验整数问题. 请教关于WEB打印范围的问题,document.all.WebBrowser.ExecWB 请教sql设计思路! ls.add() 的疑问 为什么查不出来?急!在线等!!!!!!!!!!!!11 撒分求树型结构问题 Mybatis级联插入更新,大家有没有好的解决方式 hibernate 保存数据 将一个字符串在js中转变成数据然后相加
包含检查文件格式、文件大小等功能
很好用
ajax 也行
下开源代码 插件都可以办到
^_*
//上传的文件名
private FormFile fileName;
public ActionForward upload(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获取从页面表单中提交过来的值
UploadActionForm iaf = (UploadActionForm )form;
FormFile myFile = iaf.getFileName();
if(myFile != null){
//将上传的文件流保存到磁images/item下
//String realPath = request.getContextPath().getRealPath("/images/upload");
//System.out.println("realpath" + );
//FileOutputStream fos = new FileOutputStream("C:\\upload\\"+iaf.getUploadName() + ".gif");
FileOutputStream fos = new FileOutputStream("C:\\upload\\"+iaf.getUploadName()+ ".gif");
fos.write(myFile.getFileData());
fos.flush();
fos.close();
}
return mapping.findForward("success")