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?
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
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.
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.
Regards,
Udhaya Kumar D