7

Greetings!!

I am trying to count total numbers of files have been selected or dropped in file dropbox in AjaxFileUpload controller. It shows on number of files in Queue. I need to access the numbers of files in queue. How could I do that. I am trying to write onchange event for AjaxFileUpload but it's not working which works for ASP File Uploder.

It will be helpful if I get the number of files have been selected on AjaxFileUpload change.

Thanks

Sultan
  • 69
  • 4
  • In code behind....I want to get the count of all images in the queue waiting to be uploaded....protected void ajaxUploadImage_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { – John Apr 27 '17 at 09:58
  • @john wat actually you need on upload complete – Krsna Kishore May 01 '17 at 12:29
  • @Sultan can you share the code that you tried. so we can get clear idea what are you trying to do ! – Zulqarnain Jalil May 02 '17 at 07:58

3 Answers3

3

You can count number of file uploaded successfully from JavaScript by using OnClientUploadComplete event. Please check below:

AjaxFileUpload Code:

<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" OnClientUploadComplete="uploadcomplete" OnUploadComplete="AjaxFileUpload1_UploadComplete" Mode="Auto" runat="server" /> 

JavaScript Ccode:

<script type="text/javascript"> 
    var totalUploaded = 0; 
    function uploadcomplete()  
    {  
        totalUploaded += 1;
    }  
</script> 

For more details about this, please check AJAX Control Toolkit Tutorial: AjaxFileUpload.

csharpbd
  • 3,786
  • 4
  • 23
  • 32
1

As for my understanding: AjaxFileUpload.js library doesn't support multiple uploads by itself. So you have to implement the multi-file upload by yourself. There are others libraries that support multiple files upload out of the box: Fine Uploader 5 seen to be a nice one.

If you need to use AjaxFileUpload you can follow this stackoverflow question that is related of what you want to do upload multiple files with ajaxFileUpload with different file ids . Then you can add a counter for as many times as you call the function.

Community
  • 1
  • 1
Gi1ber7
  • 632
  • 1
  • 11
  • 22
1

you can use "UploadComplete" event to do this

   protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
                {
                   HttpFileCollection uploads = HttpContext.Current.Request.Files;
                    int NoOfFiles = uploads.Count
    }
Zulqarnain Jalil
  • 1,679
  • 16
  • 26