0

I am using file upload control with AllowMultiple set. I also defined a client side onChange().

<label runat="server" id="lblFU" for="fuAttachments" class="control-label btn btn-default" style="cursor: pointer">
    <i class="fa fa-paperclip fa-lg" aria-hidden="true"></i>Add Attachment</label>
    <asp:FileUpload runat="server" ID="fuAttachments" AllowMultiple="true" class="hidden" ClientIDMode="Static" onchange="onChange(this)" />           

I am trying to loop through selected files and display in a table

function onChange(oFile) {debugger
    oFile.files.forEach(function (file, index) { // This is not correct, doesn't support foreach
        var fn = file.name;

        attachments.push({
            "fn": fn,
            "ct": file.type,
            "fl": file.size
        });
        // Display in table
        var markup = "<tr><td>" + fn + "</td><td><label class='control-label'>" + file.size + "</label></td></tr>";
        $(".fileList tbody").append(markup);
    });
}

How do I loop through the files?

NoBullMan
  • 2,032
  • 5
  • 40
  • 93

0 Answers0