aspose file tools*
The moose likes Struts and the fly likes File upload problem in struts 2 (emoving file attachment) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File upload problem in struts 2 (emoving file attachment)" Watch "File upload problem in struts 2 (emoving file attachment)" New topic
Author

File upload problem in struts 2 (emoving file attachment)

Manish Shinde
Ranch Hand

Joined: Mar 30, 2011
Posts: 39
hi,

I have developed file upload application in struts 2.
Here File Upload Interceptor actually deletes the the uploaded file , once the
action is executed.
so before returning success I have called function to copy.
Here is my action class



questions
1)Is there any way to tell the interceptor not to delete that file ?
2)In line 56 of code ,I have specified destination path and file name with extension.
what if I want to upload .doc file then I'll have to change extension again ?


Regards,
Manish,

Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

The FileUpload interceptor is responsible for uploading the file once the upload is once it will remove the file immediately due to security reasons so we have to handle the file. Just save the file where you want to save it.
FileUtils.copyFile(attachment, fileDestination);


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload problem in struts 2 (emoving file attachment)