Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts 2 - File upload - Update of file does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 - File upload - Update of file does not work" Watch "Struts 2 - File upload - Update of file does not work" New topic
Author

Struts 2 - File upload - Update of file does not work

Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Hi,

I'm using struts 2 and the UploadInterceptor to upload an image for an user account, it's working. The problem is whenever I try to update the uploaded photo it does not work. Struts 2 upload interceptor just ignores my new file and leave the old picture there. The new file is uploaded to same dir and with same name as the old one. Follows a code fragment from interceptor which is called while uploading:



Any clues on this?

[]s

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The upload interceptor deletes the uploaded file; it must be copied to a new location--I don't know if simply renaming it is enough.
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Humm..

Just find a solution for my problem, follows the new fragment of code and considerations:



What I did was adding some code to check if the user had already an uploaded photo and if it has I rename it. Because I only want 1 back up I check if I already have this back up and if I have I delete it before adding the new Photo.

[]s
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Just notice that sometimes the file gets locked by the server and the code I write is not able to delete or rename the files... I'll try something with timestamp but this will cause holding all uploaded photos from user..

Still accepting suggestions on this.

[]s
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 - File upload - Update of file does not work
 
Similar Threads
problem using s:action tag
Accessing a beanList Returned from JSP
LDAP AD - Autentication SSL
Struts 2 Fileupload problem
Caught a NonUnique Exception while adding more rows to the table.