Manually add file to uploaded list

Hello, I was added file upload and works great. I'm trying to merge my manual upload with uploaded files list.
File upload control works as expected, I also added Text edit control and a custom button to send text edit data to server and it returns as file name, size and extension.
How I can add this result into file upload's uploaded list?

here is screenshot


Upload text button's script:
     document.getElementById("btnUploadText").addEventListener('click', function () {
            var file1 = document.getElementById("file1").ej2_instances[0];
            console.log(file1.inputElement.innerText);
            $.ajax({
              type: "POST",
              url: '@Url.Action("UploadText", "Order")',
              data: { text: file1.inputElement.innerText },
              success: function(data){
                  console.log(data); // returns: {"name":"upload_1","size":75,"type":".txt"}
                  },
            });
        });

Thanks for help!

2 Replies

RA Ramazan May 18, 2021 06:52 PM UTC

Hello, I found javascript code to add file information into the list.


     document.getElementById("UploadFiles").ej2_instances[0].files.push({name: "test2", size: 100, type: ".txt"});
     document.getElementById("UploadFiles").ej2_instances[0].refresh();

Have a nice day!


PM Ponmani Murugaiyan Syncfusion Team May 19, 2021 06:41 AM UTC

Hi Ramazan, 

Thanks for the update. We are glad to hear that your problem has been solved. 

Regards, 
Ponmani M 


Loader.
Up arrow icon