Make upload widget display files already uploaded on page load

1 Answer 332 Views
Upload
Jose Luis
Top achievements
Rank 1
Jose Luis asked on 24 May 2022, 05:34 PM

Hi,

I would like to know if there's a way of displaying files that are already uploaded in the upload widget.
To make my inquiry clear, I want the upload widget to act as a table of the upload files it has already uploaded. The current behavior only shows the files that are added in the document at the moment  of uploading. Once you navigate out of the page and back the upload files array gets emptied.

Thanks in advance for any response!

1 Answer, 1 is accepted

Sort by
0
Accepted
Mihaela
Telerik team
answered on 27 May 2022, 10:28 AM

Hello Jose Luis,

Indeed, you could use the Files() method of the Upload to load the files initially when the component is initialized.

For example:

//View

@model List<FileViewModel>

        @(Html.Kendo().Upload()
            .Name("files")
            ...
            .Files(files =>
            {
               if (Model != null)
               {
                    foreach (var file in Model)
                    {
                        files.Add().Name(file.Name).Extension(file.Extension).Size(file.Size);
                    }
               }
            })
        )

Here is a REPL example for your reference: https://netcorerepl.telerik.com/GwEJmBlk27lLr36k48

 


Regards, Mihaela Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Upload
Asked by
Jose Luis
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or