Get the filename of a fileupload in a document through JavaScript

file-upload, javascript

Solution

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 %>");

Problem

``` var fu1 = document.getElementById("FileUpload1"); ``` How can I get the filename of the fileupload control with `id FileUpload1`?

Original source