I am having trouble retrieving filenames and displaying them in the label lbName
. I tried using asp:FileUpload
but it's not working. Here is my code:
<asp:FileUpload ID="FileUpload1" AllowMultiple="true" runat="server" Onchange="upload()"/> <asp:Label ID="lbName" runat="server" ForeColor="Gray" Visible="True"></asp:Label>
Here is the JavaScript code I am using:
function upload() {
var name = "";
var files = document.getElementById("<%= FileUpload1.ClientID %>");
for (var i = 0; i < files.length; i++) {
name = name + (files[i].name) + ";";
}
document.getElementById("lbName").value = "1: " + name;
}