Note that there are some explanatory texts on larger screens.

plurals
  1. POInaccurate progress bar when uploading large files using ASP.NET and Uploadify?
    primarykey
    data
    text
    <p>I've got an ASP.NET web application (utilizing WebForms) and am using <a href="http://www.uploadify.com" rel="nofollow noreferrer">Uploadify</a> to handle uploading large files. This is done by posting the file to an HttpHandler.</p> <p>Example of code (simplified for demonstration purposes):</p> <pre><code>$(".uploadify").uploadify({ 'uploader': '/uploadify/uploadify.swf', 'script': 'SaveUploadedFile.ashx', 'cancelImg': '/uploadify/cancel.png', 'queueID': 'fileQueue', 'auto': true, 'multi': false, 'method': 'post', onSelect: function(e, queueId, file) { alert(file.name + " selected"); }, onComplete: function(e, queueId, file, response, data) { alert("complete: " + response); }, onCancel: function(e, queueId, file, data) { alert("cancel"); } }); </code></pre> <p>The HttpHandler that receives the file is fairly simple:</p> <pre><code>public void ProcessRequest(HttpContext context) { Debug.WriteLine("Save file"); if (context.Request.Files.Count == 0) throw new SystemException("No files uploaded"); // Get the file HttpPostedFile file = context.Request.Files.Get(0); Debug.WriteLine("Got file: " + file.FileName + ", Length: " + file.ContentLength); // Save it string guid = Guid.NewGuid().ToString(); string path = Path.Combine(Path.GetTempPath(), guid + ".tmp"); file.SaveAs(path); Debug.WriteLine("Saved to path: " + path); // Update response and return guid context.Response.StatusCode = 200; context.Response.Write(guid); Debug.WriteLine("All Done"); } </code></pre> <p>The problem is that the progress bar being displayed doesn't actually reflect the progress of the upload, and shows the upload as being complete long before the file is actually uploaded. Therefore, the user interface effectively appears like it is doing nothing while the progress bar stays at 100%, until the file is complete.</p> <p>In some cases, the upload simply fails after reaching 100%, with the OnComplete event never getting fired, almost like the response from the HttpHandler is getting lost in transit, even though the file is saved.</p> <p>I've tried both <a href="http://www.flajaxian.com/" rel="nofollow noreferrer">Flajaxian</a> and <a href="http://www.swfupload.org/" rel="nofollow noreferrer">SWFUpload</a>, and experienced similar issues with the progress bar being completely out of sync with actual upload progress, indicating completion well before the upload was actually complete.</p> <p>This problem is not apparent when testing locally, or with small files (typically under a few megabytes) as these tend to upload fairly quickly and there's little or no lag between the file being uploaded and the progress bar completing.</p> <p>Is there any way of using a Flash upload solution (such as Uploadify) with an ASP.NET web application and have the progress bar better represent the actual progress of the upload?</p> <p><strong>Update:</strong> Eventually, I gave up trying to use a flash based uploader as they seemed a bit too awkward, especially the progress bar, which didn't represent the actual progress of the upload at all. Replaced this with <a href="http://www.brettle.com/neatupload" rel="nofollow noreferrer">Brettle NeatUpload</a> instead which works much better.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload