File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes File Upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "File Upload" Watch "File Upload" New topic

File Upload

Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
Hi All,

I have a form in which user can attach files and fill the details in the form and submit. He can attach any number of files and can delete the attached files. Once he attaches files, it will be displayed and he will fill the rest of the form and submits. The problem is i dont know how to handle this scenario. I came up with two ideas.
1. On attaching the file store it temp. in a table in database. Once the user fills the rest of the form and submit save it to the main table. The problem in this apporach if he going to cancel the form then i wnt to delete the attached files, it can be done if he clicks on the cancel button. But he closes browser clicks on some other thing in the menu i could not handle.
2. Display only the file name and on submit based on the path get the data, but in this case how to handle this because on submission of the form only the path goes to the server and u cant retreive it.

Anybody could suggest a better idea for solving this i could be great help for me.
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
As far as the user canceling. Assign each user a unique id into session, use this to track 'temporary' files. Create session listener that deletes all temporary files of the unique id when session is destroyed.
SCJP 1.4
I agree. Here's the link:
subject: File Upload
jQuery in Action, 3rd edition