Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count total selected files on AjaxFileUpload on change java script

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

like image 872
Sultan Avatar asked Nov 18 '16 09:11

Sultan


2 Answers

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.

like image 109
csharpbd Avatar answered Oct 15 '22 01:10

csharpbd


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.

like image 32
Gi1ber7 Avatar answered Oct 15 '22 01:10

Gi1ber7