This is not a new thing by any means, but I found it difficult to find a single place where it was explained and the code made available, so here we go ...
This can be done by an HttpModule which will interrupt the usual request flow and allow for progress to be monitored. The key is to get hold of the HttpWorkerRequest and read the data as it comes in, keeping a track of the number of bytes received against the total gives you the progress.
Posting the file(s) and checking the progress can be done using AJAX, I've used the jQuery Form plugin.
You need to decide how big the files you are going to allow will be. You can increase the maxRequestLength to ~2GB in your web.config if you like, but fundamentally you will be limited to the physical memory available to store the request in a byte array when passed on as preloaded content in step 6 above, on a shared server this will be considerably less than 2GB.
<system.web> <otherstuff /> <httpRuntime maxRequestLength="2097151"/> </system.web>
You will need to register the module in your web.config httpModules
<system.web>
<httpModules>
<others />
<add name="ProgressModule" type="Antix.Web.ProgressModule"/>
</httpModules>
</system.web>Download the MVC project below, with all the code mentioned
Requires .NET 3.5, ASP.NET MVC 1.0
File Upload with Progress Example Project
p.s. the module can be used in non-MVC projects, its just the example is an MVC project.
The above post is indeep very useful. This has save lot of my time in solving the issues with uploading files which are more in Size(above 2MB).
Thanks a lot for the Information .
i downloaded the sample but it seems a bit buggy.
the site.css is empty, not sure what should go in there.
the uploading works, it makes the ajax calls and it gets a number back but nothing on the view changes.. ie there is no visual feedback.
Must be an old version, was relying on an old link to jquery ui css - updated now
| < | May 2012 | |||||
|---|---|---|---|---|---|---|
| S | M | T | W | T | F | S |
| 29 | 30 | 1 | 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | 1 | 2 |
Add-ins AJAX ASP.NET MVC Browsers C# Caching CodeDom Compression CORS CSS CV Data Database DependencyResolver Development Dynamic Entity Framework Error Handling Extend File Upload Forms GDI+ HTML HTML Editor HTTP Interfaces JavaScript JQuery MCE MetadataProvider MSBuild Numbers Objects Patterns Progressive Enhancement Projects Publish Regex Resources Security SEO SMTP Source Control Strings Sub-Collections TDD Templates Tools Twitter User Interface WCF Web Development WHS WMC XLinq XML
1 hours ago
TheNextWeb
Bing's search API now live on the Windows Azure Marketplace http://t.co/utX8uOuG by @alex
15/05/2012
WindowsAzure
Announcing the MEET Windows Azure Event! Streamed online June 7th. Register at http://t.co/bObzTAuL #MEETAzure #WindowsAzure
One hour ago
commadelimited
Buy the @amazon Kindle version of mine and @cfjedimaster's @jquerymobile book for $10 today: http://t.co/PWRZ2dkd
just now
WAPForums
UpdateMessage() method not available in SDK 1.6? http://t.co/fyORSB1T Windows #Azure
just now
kamoswin
Microsoft Corporation : Pariveda Solutions Builds Cloud Applications on Windows Azure - 4-traders... http://t.co/M5o5TxdL #cloud #azure