In case you have not guessed, asking someone to just "give me code" is not
the best policy on any forum/mailing list. You can either a) use Google to
find someone who has posted code b) Learn to do it yourself. Either way
its not really a Struts related question.....
All that said, try this although I fear it will only cause more problems
than it will help you:
private void saveFile(File file, String savePath, String fileName)
throws CourseResourceException{
File dirPath = new File(savePath);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
try{
//retrieve the file data
InputStream stream = new FileInputStream(file);
//write the file to the file specified
OutputStream bos = new FileOutputStream(savePath + File.separator +
fileName);
int bytesRead;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
stream.close();
}catch(Exception e){
throw new CourseResourceException("Could not save file to file
system.",e);
}
}
PEGASUS84 wrote:
>
>
> excuse me
> has some one the code to save the upload file in a specific directory?
>
--
View this message in context:
http://www.nabble.com/file-upload-tp23282289p23290304.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]