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

Upload and display image on form

4 Answers 1350 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Veteran
Jonathan asked on 02 May 2020, 09:48 PM

Hi

Are there any samples/ideas of how to - uploading an image and then displaying the image on a form?

I'm trying to upload and image to CosmosDB and then show the uploaded image on a form.

 

thx in advance

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 04 May 2020, 12:51 PM

Hi Jonathan,

You can use the OnSuccess event to know when a file is uploaded, so you can trigger logic on the view that will display the image. For example, have a data collection that keeps the info about the uploaded files in the view (similar to our overview demo) and render images for them once they are uploaded (e.g., add another flag to the file descriptor model). You can even send some additional information from the server (e.g., some ID from the database that you can use in the src attribute of the <img /> tag to point it to the correct handler).

 

Regards,
Marin Bratanov
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.
0
Jonathan
Top achievements
Rank 1
Veteran
answered on 09 May 2020, 03:10 PM

How do you load the file into a FileStream... so I can write to a BLOB

thx again

0
Accepted
Marin Bratanov
Telerik team
answered on 11 May 2020, 02:00 PM

Hi,

You can see an example way of writing a file to a stream in the following controller: https://docs.telerik.com/blazor-ui/components/upload/overview. Generally, it is up to the particular endpoint to handle the file and any underlying data storage (be that a file system, database, cloud or something else). For example, a .NET Core API would receive the file as an IFormFile that exposes a couple of methods for working with streams: https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iformfile?view=aspnetcore-3.1.

 

Regards,
Marin Bratanov
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.
0
Jonathan
Top achievements
Rank 1
Veteran
answered on 11 May 2020, 05:19 PM
thx again
Tags
Upload
Asked by
Jonathan
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Jonathan
Top achievements
Rank 1
Veteran
Share this question
or