jsp上传出错,请大侠帮忙;控制台报错: Files' name is invalid or does not exist 5
页面报错:org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/biyesheng...
页面报错:org.apache.jasper.JasperException: An exception occurred processing JSP page /biyesheng_add_post.jsp at line 68
65: Integer its = new Integer(i);
66: rname = its.toString();
67: System.out.println(smart.getFiles());
68: smart.getFiles().getFile(0)
69: .saveAs("../UploadFile/zhaopian/" + rname + "." + ext);
70: zhaopian = "../UploadFile/zhaopian/" + rname + "." + ext; 展开
65: Integer its = new Integer(i);
66: rname = its.toString();
67: System.out.println(smart.getFiles());
68: smart.getFiles().getFile(0)
69: .saveAs("../UploadFile/zhaopian/" + rname + "." + ext);
70: zhaopian = "../UploadFile/zhaopian/" + rname + "." + ext; 展开
1个回答
展开全部
说得是文件名无效或者不存在,你可以先判断目录是否存在,再使用物理地址保存
1、首先目录也要存在
String uploadpath=request.getSession().getServletContext().getRealPath("/")+"upload\\";
if(!new File(uploadpath).isDirectory())
new File(uploadpath).mkdirs();
2、
File source = new File(uploadpath+gettime+"_"+file.getOriginalFilename());
下面就可以保存了。
1、首先目录也要存在
String uploadpath=request.getSession().getServletContext().getRealPath("/")+"upload\\";
if(!new File(uploadpath).isDirectory())
new File(uploadpath).mkdirs();
2、
File source = new File(uploadpath+gettime+"_"+file.getOriginalFilename());
下面就可以保存了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询