var fu1 = document.getElementById("FileUpload1");
how can i get the filename of fileupload control with id FileUpload1
var fu1 = document.getElementById("FileUpload1");
how can i get the filename of fileupload control with id FileUpload1
Try the value
property, like this:
var fu1 = document.getElementById("FileUpload1");
alert("You selected " + fu1.value);
NOTE: It looks like FileUpload1
is an ASP.Net server-side FileUpload control.
If so, you should get its ID using the ClientID
property, like this:
var fu1 = document.getElementById("<%= FileUpload1.ClientID %>");
Try document.getElementById("FileUpload1").value
this value should have a path for a file to be uploaded, just strip all dirs from that value and you will have file name.