Upload and display image on form

5 posts, 2 answers
  1. Jonathan
    Jonathan avatar
    116 posts
    Member since:
    Jan 2014

    Posted 02 May Link to this post

    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

     

  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    5361 posts

    Posted 04 May Link to this post

    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.
  3. Jonathan
    Jonathan avatar
    116 posts
    Member since:
    Jan 2014

    Posted 09 May in reply to Marin Bratanov Link to this post

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

    thx again

  4. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    5361 posts

    Posted 11 May Link to this post

    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.
  5. Jonathan
    Jonathan avatar
    116 posts
    Member since:
    Jan 2014

    Posted 11 May in reply to Marin Bratanov Link to this post

    thx again
Back to Top