File upload problem


Web tier: servlets, JSP, Web frameworks: File upload problem

  1. File upload problem (4 messages)

    Suppose I have a registration form that spans multiple pages( say, 1-initial, 2-detail and 3-confirmation). At the Initial page, the user would like to upload a few documents from his local disk( like email attachments). But I need to save these documents only when he successfully completes page 2 and confirms on page 3(confirmation). What is the best strategy to follow here? Does struts provide any easy mechanism?
    what i am going to implements is something like this.
    The use specifies the multiple documents that he wants to upload in first page( their URI(local) uri is saved in a string collection of the FormBean that would span all three pages). in third page, I will have a hidden set of file upload controls, with value set as - value from String collection of form bean. Now, i can handle this on last confirm page submit.
    Any thoughts?

    Threaded Messages (4)

  2. File upload problem[ Go to top ]

    Yes, Struts does provides an easy mechanism to upload files. Check out <html:file> tag and/or their upload example that comes with the distribution. In your case you might have to store the form bean ( contains file(s) data) in the session but it has some drawbacks. If the user uploads huge files, lot of memory would be consumed. Or you could store it on a filesytem but you will have to keep track of the files.

    If I would have a choice, I would provide interface to upload files after confirmation. Well, thats just me.
  3. Any more views?[ Go to top ]

    Hi there thank you for your message.
    I dont have a choice but to make the upload in 1st or 2nd page.
    I was just wondering if instead of storing the whole File in session, what if I store the local file URIs in the session and make use of them in the last page
  4. Any more views?[ Go to top ]

    I don't know how you plan to implement getting the files from the client machine. Only way i know is to use is signed applet that would retrieve the files from the stored local file URLs. Again, there is complexity involved to sign the applet and stuff. Definetly not a best approach.

    I don't see any other option. Your best bet would be to read the file and write to the disk and process to next page.
  5. Any more views?[ Go to top ]

    I think, u can store all those documents into an XML (may be by reading a file and placing it between two CDATA tags..), then u can store this XML object in memory.. i am not sure of the performance impacts, however this is another way of doing :->