Blazor

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfUploader

    Show / Hide Table of Contents

    Class SfUploader

    The uploader component is useful to upload images, documents, and other files to server. The component is the extended version of HTML5 that is uploaded with multiple file selection, auto upload, drag and drop, progress bar, preload files, and validation.

    Inheritance
    System.Object
    SfBaseComponent
    SfUploader
    Inherited Members
    SfBaseComponent.OnInitializedAsync()
    SfBaseComponent.OnAfterRenderAsync(Boolean)
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.Inputs
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfUploader : SfBaseComponent

    Constructors

    SfUploader()

    Declaration
    public SfUploader()

    Properties

    AllowedExtensions

    Specifies the extensions of the file types allowed in the Uploader component and pass the extensions with comma separators.

    For example,if you want to upload specific image files, pass `AllowedExtensions` as ".jpg,.png".

    Declaration
    public string AllowedExtensions { get; set; }
    Property Value
    Type Description
    System.String

    AllowMultiple

    Specifies a boolean value that indicates whether the multiple files can be browsed or dropped simultaneously in the Uploader component.

    Declaration
    public bool AllowMultiple { get; set; }
    Property Value
    Type Description
    System.Boolean

    AutoUpload

    By default, the Uploader component initiates automatic upload when the files are added in upload queue.

    If you want to manipulate the files before uploading to server, disable the AutoUpload property.

    The buttons "upload" and "clear" will be hided from file list when AutoUpload property is true.

    Declaration
    public bool AutoUpload { get; set; }
    Property Value
    Type Description
    System.Boolean

    CssClass

    Specifies the CSS class name that can be appended with root element of the Uploader. One or more custom CSS classes can be added to a Uploader.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    DirectoryUpload

    Specifies a boolean value that indicates whether the folder of files can be browsed in the Uploader component.

    Declaration
    public bool DirectoryUpload { get; set; }
    Property Value
    Type Description
    System.Boolean

    DropArea

    Specifies the drop target to handle the drag-and-drop upload. By default, the Uploader creates wrapper around file input that will act as drop target.

    Declaration
    public string DropArea { get; set; }
    Property Value
    Type Description
    System.String

    DropEffect

    Specifies the drag operation effect to the Uploader component.

    Possible values are .

    • Copy
    • Move
    • Link
    • None
    Declaration
    public DropEffect DropEffect { get; set; }
    Property Value
    Type Description
    DropEffect

    Enabled

    Specifies a boolean value that indicates whether the Uploader allows the user to interact with it.

    Declaration
    public bool Enabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    EnableHtmlSanitizer

    Gets or sets whether to prevent the cross site scripting code in filename or not.

    Declaration
    public bool EnableHtmlSanitizer { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the component prevents the cross site scripting code in filename; otherwise,false. The default value is true.

    Remarks

    The Enable HtmlSanitizer property removes the cross-site scripting code or functions from the filename and shows the validation error message to the user.

    EnablePersistence

    Enable or disable persisting Uploader state between page reloads. If enabled, the Files state will be persisted.

    Declaration
    public bool EnablePersistence { get; set; }
    Property Value
    Type Description
    System.Boolean

    EnableRtl

    Enable or disable rendering Uploader in right to left direction.

    Declaration
    public bool EnableRtl { get; set; }
    Property Value
    Type Description
    System.Boolean

    HtmlAttributes

    You can add the additional html attributes such as styles, class, and more to the root element.

    If you configured both property and equivalent html attributes, then the component considers the property value.

    Declaration
    public Dictionary<string, object> HtmlAttributes { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    ID

    Specifies the id of the Uploader component.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    InputAttributes

    You can add the additional input attributes such as disabled, value, and more to the root element. If you configured both property and equivalent input attribute, then the component considers the property value.

    Declaration
    public Dictionary<string, object> InputAttributes { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    MaxFileSize

    Specifies the maximum allowed file size to be uploaded in bytes. The property used to make sure that you cannot upload too large files.

    Declaration
    public double MaxFileSize { get; set; }
    Property Value
    Type Description
    System.Double

    MinFileSize

    Specifies the minimum file size to be uploaded in bytes. The property used to make sure that you cannot upload empty files and small files.

    Declaration
    public double MinFileSize { get; set; }
    Property Value
    Type Description
    System.Double

    SequentialUpload

    By default, the file Uploader component is processing the multiple files simultaneously.

    If SequentialUpload property is enabled, the file upload component performs the upload one after the other.

    Declaration
    public bool SequentialUpload { get; set; }
    Property Value
    Type Description
    System.Boolean

    ShowFileList

    Specifies a boolean value that indicates whether the default file list can be rendered. The property used to prevent default file list and design own template for file list.

    Declaration
    public bool ShowFileList { get; set; }
    Property Value
    Type Description
    System.Boolean

    TabIndex

    Specifies the tab order of the component.

    Declaration
    public int TabIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    Template

    Specifies the HTML string that used to customize the content of each file in the list.

    Declaration
    public RenderFragment<FileInfo> Template { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.RenderFragment<FileInfo>

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    BytesToSizeAsync(Double)

    It is used to convert bytes value into kilobytes or megabytes depending on the size based on binary prefix.

    Declaration
    public Task<string> BytesToSizeAsync(double bytes)
    Parameters
    Type Name Description
    System.Double bytes

    Specifies the file size in bytes.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.String>

    Task.

    CancelAsync(FileInfo[])

    Stops the in-progress chunked upload based on the file data. When the file upload is canceled, the partially uploaded file is removed from server.

    Declaration
    public Task CancelAsync(FileInfo[] fileData = null)
    Parameters
    Type Name Description
    FileInfo[] fileData

    specifies the files data to cancel the progressing file.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    ClearAllAsync()

    Clear all the file entries from list that can be uploaded files or added in upload queue.

    Declaration
    public Task ClearAllAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    GetFileDetails(List<FileInfo>)

    Task which retrieves the file data.

    Declaration
    public Task GetFileDetails(List<FileInfo> file)
    Parameters
    Type Name Description
    System.Collections.Generic.List<FileInfo> file

    Specifies the file.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    GetFilesDataAsync(Nullable<Double>)

    Get the data of files which are shown in file list.

    Declaration
    public Task<List<FileInfo>> GetFilesDataAsync(Nullable<double> index = null)
    Parameters
    Type Name Description
    System.Nullable<System.Double> index

    Specifies the index.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.List<FileInfo>>

    Task.

    PauseAsync(List<FileInfo>, Nullable<Boolean>)

    Pauses the in-progress chunked upload based on the file data.

    Declaration
    public Task PauseAsync(List<FileInfo> fileData = null, Nullable<bool> custom = null)
    Parameters
    Type Name Description
    System.Collections.Generic.List<FileInfo> fileData

    specifies the files data to pause from uploading.

    System.Nullable<System.Boolean> custom

    Set true if used custom UI.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    RemoveAsync(FileInfo[], Nullable<Boolean>, Nullable<Boolean>, Nullable<Boolean>, Object)

    Remove the uploaded file from server manually by calling the remove URL action.

    If you pass an empty argument to this method, the complete file list can be cleared, otherwise remove the specific file based on its argument ("file_data").

    Declaration
    public Task RemoveAsync(FileInfo[] fileData = null, Nullable<bool> customTemplate = null, Nullable<bool> removeDirectly = null, Nullable<bool> postRawFile = null, object args = null)
    Parameters
    Type Name Description
    FileInfo[] fileData

    specifies the files data to remove from file list/server.

    System.Nullable<System.Boolean> customTemplate

    Set true if the component rendering with customize template.

    System.Nullable<System.Boolean> removeDirectly

    Set true if files remove without removing event.

    System.Nullable<System.Boolean> postRawFile

    Set false, to post file name only to the remove action.

    System.Object args
    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    ResumeAsync(FileInfo[], Nullable<Boolean>)

    Resumes the chunked upload that is previously paused based on the file data.

    Declaration
    public Task ResumeAsync(FileInfo[] fileData = null, Nullable<bool> custom = null)
    Parameters
    Type Name Description
    FileInfo[] fileData

    specifies the files data to resume the paused file.

    System.Nullable<System.Boolean> custom
    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    RetryAsync(FileInfo[], Nullable<Boolean>, Nullable<Boolean>)

    Retries the canceled or failed file upload based on the file data.

    specifies the files data to retry the canceled or failed file Set true to retry from canceled stage and set false to retry from initial stage.
    Declaration
    public Task RetryAsync(FileInfo[] fileData = null, Nullable<bool> fromcanceledStage = null, Nullable<bool> custom = null)
    Parameters
    Type Name Description
    FileInfo[] fileData
    System.Nullable<System.Boolean> fromcanceledStage
    System.Nullable<System.Boolean> custom
    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    SortFileListAsync(FileInfo[])

    Allows you to sort the file data alphabetically based on its file name clearly.

    Declaration
    public Task<List<FileInfo>> SortFileListAsync(FileInfo[] filesData = null)
    Parameters
    Type Name Description
    FileInfo[] filesData

    specifies the files data for upload.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Collections.Generic.List<FileInfo>>

    Task.

    UploadAsync(FileInfo[], Nullable<Boolean>)

    Allows you to call the upload process manually by calling save URL action.

    To process the selected files (added in upload queue), pass an empty argument otherwise upload the specific file based on its argument.

    Declaration
    public Task UploadAsync(FileInfo[] files = null, Nullable<bool> custom = null)
    Parameters
    Type Name Description
    FileInfo[] files

    specifies the files data for upload.

    System.Nullable<System.Boolean> custom

    specifies the custom files.

    Returns
    Type Description
    System.Threading.Tasks.Task

    Task.

    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved