Display image before new upload

I have this item  How to Preview Images in Syncfusion Blazor File Upload Component | Syncfusion Blogs

I need an additional item to it when loading the viewing or editing page, I need the image to be displayed as well, it would be like taking an item already registered and presenting it in the same way but without uploading it again, how can I do it?


4 Replies

VJ Vinitha Jeyakumar Syncfusion Team August 11, 2022 02:28 PM UTC

Hi Fernando,

Currently, we are validating your reported query. we will update you the further details in two business days on or before 16th August 2022.

Regards,
Vinitha


UD UdhayaKumar Duraisamy Syncfusion Team August 16, 2022 12:01 PM UTC

Hi Fernando,


We suggest you remove the below-highlighted line in the onChange event to resolve the reported issue. Please refer to the below code snippet and sample for reference.


public void onChange(UploadChangeEventArgs args)

    {

        //files = new List<fileInfo>();

        foreach (var file in args.Files)

        {

            var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), "Images");

            var fullPath = Path.Combine(pathToSave, file.FileInfo.Name);

            byte[] bytes = file.Stream.ToArray();

            string base64 = Convert.ToBase64String(bytes);

            files.Add(new fileInfo() { Path = @"data:image/" + file.FileInfo.Type + ";base64," + base64, Name = file.FileInfo.Name, Size = file.FileInfo.Size });

            content = new MultipartFormDataContent {

                    { new ByteArrayContent(file.Stream.GetBuffer()), "\"upload\"", file.FileInfo.Name }

                };

 

        }

    }


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Blazor_Upload_Preview-25981775


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Regards,

Udhaya Kumar D




FC Fernando Candido replied to UdhayaKumar Duraisamy August 16, 2022 12:28 PM UTC

It's not a problem but a necessity, it must have been poorly written.

It's about having an image uploaded before uploading.

For some reason I already had the image I want to display in the database, the user could replace it.

Before the user interacts with the upload component, a default image will already be loaded.



UD UdhayaKumar Duraisamy Syncfusion Team August 17, 2022 04:06 PM UTC

Hi Fernando,


When we try to upload multiple files the uploader will upload the files only once. If we continue to upload again some other files then the file list refreshed and the previously uploaded files will not upload again and only current files will be uploaded.


If we misunderstood the query, we request you to provide additional details about the query as mentioned below. This will help us validate the query further and provide you with a better solution.

  1. The exact issue that you are facing on your end.
  2. Simple issue replicating sample (or modify the previously shared sample).
  3. Issue replication steps.
  4. Video illustration of the issue.


Regards,

Udhaya Kumar D



Loader.
Up arrow icon