This is a migrated thread and some comments may be shown as answers.

Display existing files in an MVC form

3 Answers 985 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Reynner
Top achievements
Rank 1
Reynner asked on 20 Jul 2018, 02:19 PM

Hi,

I want to display the existing files based on the value of the HttpPostedFileBase properties in my view model. How can I achieve this without using asynchronous uploading?

I tried what is written in this blog but whenever I save the form, the value of the files are lost.

Form:
@(Html.Kendo().Upload()
                                        .Name("LogoImage")
                                        .Multiple(false)
                                        .Messages(m => m.Select("Upload"))
                                        .Validation(validation => validation
                                            .AllowedExtensions(new string[] { ".gif", ".jpg", ".png" })
                                            .MaxFileSize(2097152)
                                        )
                    )

View model:
public HttpPostedFileBase LogoImage { get; set; }

3 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 24 Jul 2018, 11:51 AM
Hello Reynner,

The files can be rendered initially in the file list of the Upload widget by using the file configuration. I am afraid that this option is available only when the Upload is in async mode. As far as I see in the provided blog post async upload is also used.
You could take a look of Initial files Demo, where it is demonstrated how to persist the previously uploaded files.
Here is also a link to StackOverflow where similar issue have been discussed. 

Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Zahid
Top achievements
Rank 1
answered on 30 Jun 2020, 06:47 AM

is there any way to maintain files for synchronized upload?

 

0
Neli
Telerik team
answered on 02 Jul 2020, 06:03 AM

Hello Zahid,

If you need to display the existing files asynchronous mode should be used. In synchronous mode, the Upload functions similarly to a standard input type="file" element, and the population of the initial files is not implemented for this mode.

Regards,
Neli
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Upload
Asked by
Reynner
Top achievements
Rank 1
Answers by
Neli
Telerik team
Zahid
Top achievements
Rank 1
Share this question
or