会报错如下:
java.io.FileNotFoundException: Source “D:\Java\Tomcat 6.0\work\Catalina\localhost\hbctoa\upload__3eb92a8a_155ec4948de__8000_00000000.tmp” does not exist
而本人在Tomcat 6.0\work\Catalina\localhost\xx目录下找到的临时文件并没有upload__3eb92a8a_155ec4948de__8000_00000000.tmp只有upload__3eb92a8a_155ec4948de__8000_00000002.tmp
所以会报错,这个该怎么解决啊。请教育。
java.io.FileNotFoundException: Source “D:\Java\Tomcat 6.0\work\Catalina\localhost\hbctoa\upload__3eb92a8a_155ec4948de__8000_00000000.tmp” does not exist
而本人在Tomcat 6.0\work\Catalina\localhost\xx目录下找到的临时文件并没有upload__3eb92a8a_155ec4948de__8000_00000000.tmp只有upload__3eb92a8a_155ec4948de__8000_00000002.tmp
所以会报错,这个该怎么解决啊。请教育。
public String execute() throws Exception { // TODO Auto-generated method stub boolean flag = true; String[] arrExtension = {".ppt",".xls",".txt",".pdf",".doc",".gif",".jpg",".jpeg",".bmp",".png"}; if(inputFiles != null && inputFiles.size() > 0){ for(int i = 0; i < inputFiles.size(); i++){ String strExtension = inputFilesFileName.get(i).substring(inputFilesFileName.get(i).lastIndexOf(".")); for(int j = 0; j < arrExtension.length; j++){ if(strExtension.equals(arrExtension[j])){ inputFilesContentType.set(i, arrExtension[j]); break; } if(j == arrExtension.length - 1){ outString = new ByteArrayInputStream("fileError".getBytes("UTF-8")); return SUCCESS; } } } User u = (User) ActionContext.getContext().getSession().get("user"); if(u != null){ List<Filetype> list = filetypeService.getAllFiletypes(); for(int i = 0; i < inputFiles.size(); i++){ String uuid = UUID.randomUUID().toString(); String path = getSavePath() + "\" + uuid; File f = new File(path, inputFilesFileName.get(i)); if(f.exists()) { f.delete(); } try{ FileUtils.copyFile(inputFiles.get(i), f); }catch(Exception e){ e.printStackTrace(); }
解决方案
40
上传文件的时候你要本人定义一个目录来保存,而你这个是临时文件