问题已经解决,但仍不知道原因。通过设置绝对路径,使得上传文件得以实现:
以及:
引自:[url]http://www.icefaces.org/JForum/posts/list/8293.page[/url]
<context-param>
<param-name>com.icesoft.faces.uploadDirectory</param-name>
<param-value>C:\Uploads</param-value>
</context-param>
<context-param>
<param-name>com.icesoft.faces.uploadDirectoryAbsolute</param-name>
<param-value>true</param-value>
</context-param>
以及:
public void essaiDeplacer(ActionEvent event){
String id = ((HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false)).getId();
InputFile inputFile =(InputFile) event.getSource();
//file has been saved
if (inputFile.getStatus() == InputFile.SAVED) {
String fileName = inputFile.getFileInfo().getFileName();
System.err.println("filename = "+fileName);
File source = new File("c:\\Uploads\\"+id+"\\"+fileName);
File destination = new File("c:\\Uploads\\"+fileName);
source.renameTo(destination);
}
}
引自:[url]http://www.icefaces.org/JForum/posts/list/8293.page[/url]