How to Monitor File Upload Progress

Last post 11-19-2009 5:37 PM by WilliamSnell. 6 replies.

Sort Posts:

  • How to Monitor File Upload Progress

    11-05-2009, 3:16 PM
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 5:47 PM
    • Glendale, AZ
    • Posts 222

    I'm wondering how to monitor the progress of a file being uploaded. Not what plugin to use, but how the information is gathered asyncronously. I've read the JavaScript doesn't have a handy API for accomplishing this, and while I've found (finally) a version that will operate when using it with ASP.NET MVC, I also need to provide a single input control for uploading multiple files. This being the case, I need to provide for upload progress bars for the current uploading file and total progress. I'm using the jQuery plugin MultiFile for handling multiple file uploads, and it works great, but the asyncUpload jQuery plugin doesn't seem to work well with it. For one thing, the asyncUpload plugin starts the upload immediately upon selection, which doesn't really work with multiple files.

    I'm primarily a C# developer, and know only enough JavaScript to use jQuery and various easily and get around the DOM. I'm not a JavaScript guru or anything close, and don't have the kind of skill required to make extensive changes to existing plugins with any speed or reliability. Still, I'm not adverse to digging in and trying, so if anyone has any advice on getting these two to work together, that would solve my immediate problem. Even so, I still want to know how to grab the upload progress information so I can create my own scripts for dealing with it.

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
  • Re: How to Monitor File Upload Progress

    11-06-2009, 1:34 PM
    • Star
      8,667 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,266

    Hello,

    File Upload , Multiple File Upload , Progress Bar etc etc have always been a hot question in forum.I will say that you can achieve f not all but certain featurs with little bit of tweaking.In general file uploading with progress bar is the most difficult combination.

    Probably you can check out the following blog on FileUpload + Updateprogress :- http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html

    The current asp.net FileUpload control is not compatible with the UpdatePanel control as the FileUpload control requires full page postback .But with the latest ajaxControlToolkit framework they have introduced a new control which can be used with UpdatePanel control.You can check out my blog for more on this :- AsyncFileUpload Control

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: How to Monitor File Upload Progress

    11-06-2009, 6:16 PM
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 5:47 PM
    • Glendale, AZ
    • Posts 222

    Thanks, but the primary question of my post is how to monitor the progress of the file upload, not what plugin to use to do it for me. Also, since I mentioned that I'm working on an ASP.NET MVC application, the issue with UploadPanels and the FileUpload controls is a moot issue, since neither of them are available in MVC applications.

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
  • Re: How to Monitor File Upload Progress

    11-13-2009, 5:14 PM
    Answer
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 5:47 PM
    • Glendale, AZ
    • Posts 222

    It was my hope to learn a bit about the inner workings of this process, but in the end I did find a plugin that took care of things nicely, and went with it.  

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
  • Re: How to Monitor File Upload Progress

    11-13-2009, 10:29 PM
    • Star
      8,667 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 7:37 AM
    • Bangalore
    • Posts 1,266

    Good , That the issue is resolved . But can you please provide more details about that plug-in so that other will also be benifited from that .

    Regards
    Pawan Mishra

    Too many eyes doesn't make a good code !!!

    .Net 360°
  • Re: How to Monitor File Upload Progress

    11-13-2009, 11:13 PM

    primary all person use Flash [actionscript] , Silverlight control for this. but if you not like this use ajax & jquery control for this .

    in my opnenion use ajax for Monitor File Upload Progress

    for Monitor File Upload Progress in silverlight go to silverlight 's official site

    Regard
    Anirudha Gupta
    url:http://anirudhagupta.blogspot.com

    Mark As answer if i truely helped you

    learn from videos


    Read our Blog
    Mark as answer if your problem is solved
  • Re: How to Monitor File Upload Progress

    11-19-2009, 5:37 PM
    • Member
      97 point Member
    • WilliamSnell
    • Member since 09-24-2008, 5:47 PM
    • Glendale, AZ
    • Posts 222
     

    The component I found that worked the best was Uploadify. Like nearly every one of the file upload components that provides a progress bar, Uploadify was made by default to work with PHP. However, the 'script' parameter to the uploadify function accepts a Controller method just as easily. It was very easy to hook up. Besides providing a progress bar, it also allowed for multiple files to be uploaded through a single upload control. To use this component, just add the reference statements to the javascript, flash and other necessary files (check the Uploadify site and see the page source for their demo for a complete working code sample), and add a call to 'uploadify' for each input control you want to have upload progress and multiple uploads for. This is what the call to the uploadify method looked like in my app:

    $('#UploadControlID').uploadify({
           'uploader': '../../Content/uploadify.swf',
           'script': '/File/Upload/<%= Model.Asset.ID %>',
           'cancelImg': '../../Content/cancel.png',
           'fileDataName': 'UploadComponentID',
           'multi': 'true',
           'fileExt': '*.pdf; *.jpg; *.gif; *.png; *.xml;',
           'fileDesc': 'Select files of type .pdf, .jpg, .gif, .png, or .xml',
           onComplete: function()
           {
               $.get("/File/Index/<%= Model.Asset.ID %>", function(data)
               {
                   $("#FileDetails").html(data);
                });
            }
        });

    Notice that, in the 'script' parameter, I've included a bit of ASP.NET code right in with the path to the Controller method. This is due to the fact that starting the upload through this component DOES NOT fire off a form 'submit'. You can still access the uploaded files in your Controller logic from the Request.Files colllection, but form variables are not available. I needed the primary key of the asset this file was being uploaded for, and so was keeping that value in a hidden variable on the form. Since I couldn't use that approach with Uploadify, I simply grabbed it from the Model and rolled on.

    The last thing you need is a link that causes the Uploadify component to start the uploads(unless you've set it to start immediately, which I really don't like). On their website, they've demo'd the control that kicks this off as an anchor tag with some inline pseudo javascript, which I find clunky. Their version looks like this:

     

    <a href="javascript:$('#UploadControlID).uploadifyUpload();">Upload Files</a>

     

    I decided to do it a bit differently, and here is my solution:

     

     

     

     

    // This is the code that will start the upload. Place it in your jQuery 
    // document.ready function:
    $('#UploadButton').click(function()
    {
         $('#UploadControlID).uploadifyUpload();
    });
    
    
    // Your upload control and the button to fire it off:
    <input type="file" id="UploadControlID" name="UploadControlID" size="50" />
    <input type="button" value="UploadFiles" id="UploadButton" />
    


    This removed the inline javascript and adhered more closely to 'best practices', and just looked a bit better to me. Both work just fine.

     

     

     

    It's not how hard you push in life, but who you push, that makes the difference between success and running for your life.
Page 1 of 1 (7 items)