We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

File upload: Remove a preloaded file

Hi,

I'm using Blazor webassembly with .Net6 (6.0.10) and Syncfusion 20.3.0.57.

When I use the file uploader component, I use the preload file feature so that if the user comes back to the page of the uploader, he can see the files he uploaded precedingly.

However, I can’t make the remove function work. When I click on the bin icon, I don’t get the list of files on the remove action API (IList<IFormFile> is null). As a result, I don’t know which file to delete.

Do you have a solution to remove a preloaded file?

I attached an example project with a video.

Thanks for your help.

Best regards,

François



Attachment: Preload_file_delete_66a45b22.zip

1 Reply

AA Anitha Azhagesan Syncfusion Team November 17, 2022 12:01 AM

To remove the uploaded files, in BeforeRemove event arguments you need to set PostRawFile as false.


[Index.razor]

<SfUploader ID="MyUploader"

            SequentialUpload=true

            AllowMultiple=true

            MaxFileSize=100000

            AllowedExtensions=".csv">

    <UploaderFiles>

        <UploaderUploadedFiles Name="MyFile1" Size=500000 Type=".csv" />

        <UploaderUploadedFiles Name="MyFile2" Size=500000 Type=".csv" />

    </UploaderFiles>

    <UploaderAsyncSettings SaveUrl="https://localhost:7252/api/FileUpload/Save"

                           RemoveUrl="https://localhost:7252/api/FileUpload/Remove" />

    <UploaderEvents BeforeRemove="@BeforeRemovehandler"></UploaderEvents>

</SfUploader>

 

 

@code {

    private void BeforeRemovehandler(BeforeRemoveEventArgs args)

    {

        args.PostRawFile = false;

    }

}



[Controller]

public void Remove(string MyUploader) // In the controller side the file name will be received as a string.

        {

            Response.Clear();

            Response.StatusCode = 200;

            //Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File removed successfully";

        }


[Screenshot]



Loader.
Live Chat Icon For mobile
Up arrow icon