Put a download control on your page
<asp:FileUpload ID="FileUpload1" runat="server"/>
Create an http handler to handle file upload:
public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { HttpPostedFile fileToUpload = context.Request.Files["Filedata"]; string pathToSave = HttpContext.Current.Server.MapPath("~/Files/") + fileToUpload.FileName; fileToUpload.SaveAs(pathToSave);
Take a look if you can integrate the plugin for upload, for example uploadify into a project (jQuery required).
<script type = "text/javascript"> $(document).ready(function() { $("#<%=FileUpload1.ClientID %>").uploadify( { 'swf': 'Scripts/uploadify.swf', 'uploader': 'Handler.ashx', 'auto': true, 'buttonText': 'Select File(s)' }); }); </script>
If you cannot do this, you need to understand how ajax works
Ajax usually uses XMLHttpRequest, which does not allow you to encode and send local files to the server.
You can use Flash swf to handle loading on the same page or use a form that has the goal of an invisible iframe 1x1.
I found the code posted on this blog post about uploading files to asp.net
source share