views:

263

answers:

3

var fu1 = document.getElementById("FileUpload1");

how can i get the filename of fileupload control with id FileUpload1

+2  A: 

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 %>");
SLaks
15 secs, good Job X-)
astander
+1  A: 

Try

var fu1 = document.getElementById("FileUpload1").value;
astander
A: 

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.

RaYell