• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic