Skip to content Skip to sidebar Skip to footer

How Can I Do A File Upload And Return Results To The Same Page?

I need to do a file upload and return the results to the same page. The
also has a couple of data fields that will be sent in the POST. I can't use HTML 5 due to limi

Solution 1:

I would suggest you take a look at how the jQuery Form Plugin does "legacy" file uploads. Basically it uses an iframe to submit the form in the background. http://malsup.com/jquery/form/#file-upload

Solution 2:

The generally accepted method outside of Flash, Silverlight, and the HTML5 File API, is to have your <form> post to an invisible <iframe> on the page.

The <iframe> location is the page or file handler that uploads your file under the hood. You then have a javascript function running on the main page, that polls your server periodically and checks to see if the download has been completed.

When you upload the file to the <iframe>, you need some way of identifying the upload that both the client and server know. One way to do this is to generate a GUID on the client, and post it along with the file and your other data fields. The server should keep hold of that GUID before receiving the file data and track the progress of the upload by linking the progress and the GUID together. Since the client generated already knows the GUID, it can send requests to the server to get the progress of that upload by sending the what it generated.

Solution 3:

I ended up using the jQuery Form Plugin. It supports sending basic auth credentials in the header with this option:

headers  : { Authorization: basicAuthCredentials}

which I also need to do.

Post a Comment for "How Can I Do A File Upload And Return Results To The Same Page?"