hi
i have uploaded file successfully but i am now trying to save the file using
following code it is not taking FileUtils and pls suggest if there is any
other alternative.
import static java.io.File.separator;
import java.io.File;
import java.lang.Object;
import java.text.MessageFormat;
import org.apache.commons.io.FileUtils
;
import com.sun.deploy.cache.Cache;
/**
* Created by IntelliJ IDEA.
* User: Owner
* Date: Sep 9, 2009
* Time: 10:22:18 AM
* To change this template use File | Settings | File Templates.
*/
public class UploadXlsAction extends BaseAction {
private File file;
private String fileFileName;
private String fileContentType;
private UploadXlsAction upload;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String execute() throws Exception{
this.file=getFile();
this.fileFileName=getFileFileName();
String filepath=file.getAbsolutePath();
System.out.println(file+fileFileName);
return "success";
}
public void uploaded(File file, String fileName){
/* File dir = new File(directoryName);
if (!dir.exists()) {
dir.mkdir();
}*/
String targetPath = MessageFormat.format("C:/Program Files/Apache
Software Foundation/Tomcat
5.5/webapps/jnewsletter/WEB-INF/classes/com/neevtech/newsletter/resources{0}{1}",
File.separator, fileName);
File fileDestination = new File(targetPath);
try{
FileUtils fl=new FileUtils();
fl.copyFile(file, fileDestination);
}catch(Exception e)
{
System.out.println(e);
}
}
}
--
View this message in context:
http://www.nabble.com/how-to-save-uploaded-file-tp25381036p25381036.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]