File upload syntax using Blazor Synfussion Control


@using JR_PDFtoExcel.Data;
@inject PdfService PdfService

<PageTitle>Schedule F</PageTitle>

<h1>Schedule F</h1>
<SfUploader AllowMultiple="false" AutoUpload="false" AllowedExtensions=".pdf" >
    <UploaderEvents ValueChange="OnChange" OnClear="ClearMsg"></UploaderEvents>
</SfUploader>

@if (LoadMsg == "File is loading...")
{
    <Wave />   
}
@LoadMsg

@code {

    public string? LoadMsg { get; set; }


    private async Task<bool> OnChange(UploadChangeEventArgs args)
    {
        foreach (var file in args.Files)
        {
            LoadMsg = "File is loading...";
            var path = "wwwroot/" + file.FileInfo.Name;
            FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
            file.Stream.WriteTo(filestream);
            filestream.Close();
            file.Stream.Close();
            LoadMsg = "File loaded...";
            //  call the function to convert PDF to Excel
           //await PdfService.ExcelScheduleF(ExcelfilePath);
        }
         await Task.Delay(1);
         return true;
    }

     private void ClearMsg()
    {
        LoadMsg = "";
    }

}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.