HxInputFile

Wraps HxInputFileCore as Bootstrap form control (incl. Label etc.)

Limit file size and/or accepted file types

<HxInputFile Label="Image" Accept="image/*,.custom" MaxFileSize="500000" />

Simple single file upload

OriginalFileName:
ContentType:
Size: bytes
LastModified:
ResponseStatus:
ResponseText:

Complex demo

FileIndex Filename Progress ContentType Size LastModified ResponseStatus ResponseText

Completed: bytes in files

API

Parameters

Name Type Description
UploadUrl string URL of the server endpoint receiving the files.
Multiple bool Single false or multiple true files upload.
Accept string Takes as its value a comma-separated list of one or more file types, or unique file type specifiers, describing which file types to allow. MDN Web Docs - HTML attribute: accept.
MaxFileSize long? The maximum files size in bytes. When exceeded, the OnFileUploaded returns 413-RequestEntityTooLarge as FileUploadedEventArgs.ResponseStatus. Default is null (unlimited).
Label string Label to render before input (or after input for Checkbox).
LabelTemplate RenderFragment Label to render before input (or after input for Checkbox).
Hint string Hint to render after input as form-text.
HintTemplate RenderFragment Hint to render after input as form-text.
CssClass string Custom CSS class to render with wrapping div.
LabelCssClass string Custom CSS class to render with the label.
InputSize InputSize? Size of the input.
InputCssClass string Custom CSS class to render with the input element.
Enabled bool?

Other properties

Name Type Description
FileCount int Last known count of associated files.

Event Callbacks

Name Type Description
OnChange EventCallback<InputFileChangeEventArgs> Gets or sets the event callback that will be invoked when the collection of selected files changes.
OnProgress EventCallback<UploadProgressEventArgs> Raised during running file upload (the frequency depends on browser implementation).
OnFileUploaded EventCallback<FileUploadedEventArgs> Raised after a file is uploaded (for every single file separately).
OnUploadCompleted EventCallback<UploadCompletedEventArgs> Raised after a file is uploaded (for every single file separately).

Methods

Method Returns Description
GetFilesAsync() Task<FileInfo[]> Gets list of files chosen.
StartUploadAsync(string accessToken) Task Starts the upload.
UploadAsync(string accessToken) Task<UploadCompletedEventArgs> Uploads the file(s).

Static properties

Property Type Description
Defaults InputFileDefaults Application-wide defaults for the HxInputFile.

HxInputFileCore

Raw component extending InputFile with direct upload.

API

Parameters

Name Type Description
UploadUrl string URL of the server endpoint receiving the files.
Multiple bool Single false or multiple true files upload.
Accept string Takes as its value a comma-separated list of one or more file types, or unique file type specifiers, describing which file types to allow. MDN Web Docs - HTML attribute: accept.
MaxFileSize long? The maximum files size in bytes. When exceeded, the OnFileUploaded returns 413-RequestEntityTooLarge as FileUploadedEventArgs.ResponseStatus. Default is long.MaxValue (unlimited).
Id string Input element id.
AdditionalAttributes IDictionary<string, object>

Other properties

Name Type Description
FileCount int Last known count of associated files.

Event Callbacks

Name Type Description
OnProgress EventCallback<UploadProgressEventArgs> Raised during running file upload (the frequency depends on browser implementation).
OnFileUploaded EventCallback<FileUploadedEventArgs> Raised after a file is uploaded (for every single file separately).
OnUploadCompleted EventCallback<UploadCompletedEventArgs> Raised when all files are uploaded (after all OnFileUploaded events).
OnChange EventCallback<InputFileChangeEventArgs>

Methods

Method Returns Description
StartUploadAsync(string accessToken) Task Initiates the upload (does not wait for upload completion). Use OnUploadCompleted event.
UploadAsync(string accessToken) Task<UploadCompletedEventArgs> Uploads the file(s).
GetFilesAsync() Task<FileInfo[]> Gets list of files chosen.

Static properties

Property Type Description
Defaults InputFileCoreDefaults Application-wide defaults for the HxInputFileCore.
An unhandled error has occurred. Reload 🗙