Project Description
This is a very simple asp.net MVC web application showing how you can make an Ajax like file upload.

This is a very simple asp.net MVC web application showing how you can make an Ajax like file upload.

It is not possible to upload a file to the server through Ajax because the access to the local file system using JavaScript is forbidden but we can use a hidden IFrame in order to obtain an Ajax like behavior. This can be done in the following way:

1. Create a form element that contains a file upload, an IFrame and a button.
2. Set the name attribute of the child IFrame to a value (ex: uploadIframe)
3. Set the target attribute of the containing form element to the name of the child iFrame (uploadIframe). The target attribute specifies where to open the action URL.
4. In order to know the result of the upload, the IFrame will contain some JavaScript code that will set the result of the operation.

You can see my blog post here: http://codeutil.wordpress.com/2013/03/05/ajax-like-file-upload/

Last edited Mar 5, 2013 at 3:27 PM by Mightymada, version 2