String date2="2009/09";
String userName="2009/09/23_12521142.jpg";
if(uploadForm.getThefile()!=null){
FormFile file1=uploadForm.getThefile();
String dir=request.getSession(true).getServletContext().getRealPath("/image/"+date2);
OutputStream out=null;
out=new FileOutputStream(dir+"/"+userName);
out.write(file1.getFileData(), 0, file1.getFileSize());
out.flush();
}F:\workspace\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\MySchool\image\2009\09\2009\09\23_1253711821.jpg (系统找不到指定的路径。)我就是想在WebRoot下的image下的2009下的09文件夹下的上传一个名为"2009/09/23_12521142.jpg" 的图片怎么就这么难
File file = new File(dir);
file.makeDirs();
再说 String dir=request.getSession(true).getServletContext().getRealPath("/image/"+date2);
这个获取是tomcat的路径
File file = new File(dir);
file.makeDirs();
上面是我前面回的
可以用out=new FileOutputStream(new File(file,userName));//这样是在每一个参数的目录下新建一个文件
你先到WebRoot下的image下的2009下的09文件夹下随便建一个图片或文本试试
你要是能把它的名字给命名成2009/09/23_12521142的话,那你就牛啦因为“/”在文本名里是不能出现的呀。。你试一试看就感觉到啦