2

I am using jquery.MultiFile.js for uploading the file with asp:FileUpload control.

<asp:FileUpload ID="fuFileUpload" runat="server" maxlength="1"
ContentEditable="false" />

I am accessing the uploaded file using following java script code

var elem = document.getElementById("<%=fuFileUpload.ClientID%>");
var names = [];
for (var i = 0; i < elem.files.length; ++i) {
   names.push(elem.files[i].name);
}

Which will work properly as expected.

Problem: Problem is that when we upload the file then remove the file with (x) button provided in jquery.MultiFile.js. and again upload the file.

elem variable

getting null in this case.

Please Help

What I have tried:

tried to get file in jquery with

// Get posted files 
var files = $("#<%=fuFileUpload.ClientID %>").get(0).files;

Markus Safar
  • 6,324
  • 5
  • 28
  • 44
  • 1
    If you inspect the `` element in browser you can check its ID. Does it change when you remove and re-add a file? – Lesley Feb 12 '16 at 16:38
  • Thanks for Help. As per your suggestion i inspect element. And found the reason for the issue. When removing the file and re-adding the file file upload control ID changes to fuFileUpload_F1. Resolve this issue by using class selector. So now i accessing the file using the javascript var files = $(".MultiFile-applied").get(0).files; – Vikas Khartude Feb 13 '16 at 06:05

0 Answers0