How to get binary file from Blazor File Uploader

Answer:

We can get the uploaded files as file stream in the ValueChange event argument as like below code snippet.

<SfUploader>

<UploaderEvents ValueChange="OnChange">UploaderEvents>

SfUploader>

@code {

private void OnChange(UploadChangeEventArgs args)

{

foreach (var file in args.Files)

{

var path = @"path" + file.FileInfo.Name;

FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);

file.Stream.WriteTo(filestream);

filestream.Close();

file.Stream.Close();

}

}

}


Documentation link here.


Loader.
Up arrow icon