Class UploadFiles
Specify the details of the uploaded files in the class.
Inheritance
System.Object
UploadFiles
Namespace: Syncfusion.Blazor.Inputs
Assembly: Syncfusion.Blazor.dll
Syntax
public class UploadFiles : Object
Constructors
UploadFiles()
Declaration
public UploadFiles()
Properties
File
Gets the data of a file selected from an SfUploader component.
Declaration
public IBrowserFile File { get; }
Property Value
Type | Description |
---|---|
Microsoft.AspNetCore.Components.Forms.IBrowserFile | Microsoft.AspNetCore.Components.Forms.IBrowserFile |
Remarks
/// The Fileproperty is typically used to handle file uploads in a Blazor application.
It represents the file selected by the user in the browser and provides access to the file's metadata,
such as the file name, size, and content type. To read the contents of the uploaded file,
call the OpenReadStream()
method of the IBrowserFile
interface, which returns a stream that you can use
to read the file data.
Examples
<SfUploader AutoUpload="true">
<UploaderEvents ValueChange="@OnChange"></UploaderEvents>
</SfUploader>
@code{
private async Task OnChange(UploadChangeEventArgs args)
{
try
{
foreach (var file in args.Files)
{
var path = @"D:\" + file.FileInfo.Name;
FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
await file.File.OpenReadStream(long.MaxValue).CopyToAsync(filestream);
filestream.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
FileInfo
Gets the FileInfo object that provides details of the selected file such as name, size, status, and more.
Declaration
public FileInfo FileInfo { get; }
Property Value
Type | Description |
---|---|
FileInfo |
Stream
Gets the stream of the selected file.
Declaration
public MemoryStream Stream { get; }
Property Value
Type |
---|
System.IO.MemoryStream |