FileUpload Blazor API

FileUpload Properties

NameTypeDefaultDescription
Acceptstring"null"Sets or gets the file types that can be submitted to the server via the element. This property corresponds to the 'accept' attribute of the hidden file input which is submitted to the URL specified by the uploadUrl property.
AppendTostring"null"Appends the list with selected files to a new custom container specified by the user. If the value of the property is a string it must represent a valid id of an HTML element inside the DOM that will be used as the new container for the uploaded files list.
AutoUploadboolfalseSets or gets whether files will be automatically uploaded after selection.
DirectoryboolfalseAllows to upload a directory. Files in all subfolders will be uploaded also. This option is supported only in Firefox and Chrome.
DisabledboolfalseEnables or disables the element.
DropZoneobjectN/ADefines a custom container that will be used as the new drop zone for file uploads. The dropped files will be added in the fileUpload's list. If 'dropZone' property set to true, the default drop zone inside the element will be used instead. If set to certain id of an HTML element inside the DOM then it will be used as the drop zone.
HideFooterboolfalseHides the footer element and it's contents (Upload All, Pause All and Close All buttons).
ItemTemplateobjectN/AApplies a custom template to the file items that represent the uploaded files.
Localestring"en"Sets or gets the language. Used in conjunction with the property messages.
MessagesobjectN/ASets the various text values used in the widget. Useful for localization. The localization object has the following fields: browse, pauseFile, cancelFile, uploadFile, pauseAll, cancelAll, uploadAll. It's recommended these messages to be set before element's initialization.
MultipleboolfalseSets or gets whether multiple item uploads are allowed.
Namestring""Sets or gets the name attribute of the hidden file input which is submitted to the URL specified by the uploadUrl property.
ReadonlyboolfalseIf the element is readonly, users cannot interact with it.
ResponseHandlerobjectN/ACallback that can used to handle various server responses and error codes.
RightToLeftboolfalseSets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.
SetHeadersobjectN/ACallback function, used to change the headers of the file upload's XHR request.
ShowProgressboolfalseDisplays a progress bar at the bottom of each uploaded item to show the progress of the uploading process.
Themestring""Determines the theme. Theme defines the look of the element
UploadUrlstring""Sets or gets the upload URL. This property corresponds to the upload form's action attribute. For example, the uploadUrl property can point to a PHP file, which handles the upload operation on the server-side.
UnfocusableboolfalseIf is set to true, the element cannot be focused.
ValueobjectN/AGets the file upload value.
ValidateFileobjectN/ACallback used to validate the files immediatelly after their selection. Retuns a boolean value. If the returned value is false, the file is removed from list and a 'validationError is fired.

FileUpload Methods

NameTypeArgumentsDescription
BrowsevoidN/AOpens a popup to browse for a file.
CancelAllvoidN/ACancels all selected files. The files are removed from the list and their uploading is prevented.
CancelFilevoidint indexCancels a selected file. The file is removed from the file list and it's uploading is prevented.Args: int index - Index of the file which will be canceled.
GetValueAsync()Task<object>'N/A'Gets the &quot;Value&quot; property as Task&lt;object&gt;.
PauseAllvoidN/APauses the uploading of all files. File upload is prevented but the files remain in the file list.
PauseFilevoidint idPauses upload of a file with particular index. File upload is prevented but file ramains in the file list.Args: string id - Index of the file which will be paused.
Refreshvoid'N/A'Refreshes the Blazor Component. Performs a layout of the HTML Elements and recalculates the measurements.
Rendervoid'N/A'Re-renders the Blazor Component. This method will make a full re-render.
StateHasChangedvoid'N/A'Refreshes the state and Re-renders the Blazor Component, if necessary.
UploadAllvoidN/AUploads all selected files.
UploadFilevoidint idUploads a selected file.Args: string id - Index of the file which will be uploaded.

FileUpload Events

NameTypeDescriptionEvent Detail
OnFileSelectedEventCallback<Event>This event is triggered when a file has been selected.dynamic filename- The name of the selected file., dynamic type- The type of the selected file., dynamic size- The size of the selected file., int index- The index of the selected file.
FileSelectedevent FileUploadFileSelectedEventHandlerThis event is triggered when a file has been selected.FileUploadFileSelectedEventArgs
OnUploadCanceledEventCallback<Event>This event is triggered when a file upload operation is canceled.dynamic filename- The name of the canceled file., dynamic type- The type of the canceled file., dynamic size- The size of the canceled file., int index- The index of the canceled file.
UploadCanceledevent FileUploadUploadCanceledEventHandlerThis event is triggered when a file upload operation is canceled.FileUploadUploadCanceledEventArgs
OnUploadCompletedEventCallback<Event>This event is triggered when a file upload operation is completed.dynamic filename- The name of the canceled file., dynamic type- The type of the canceled file., dynamic size- The size of the canceled file., int index- The index of the canceled file., dynamic status- The status of the uploaded file. Whether there was an error or success.
UploadCompletedevent FileUploadUploadCompletedEventHandlerThis event is triggered when a file upload operation is completed.FileUploadUploadCompletedEventArgs
OnUploadErrorEventCallback<Event>This event is triggered when during the file upload process something happens and upload fails.dynamic filename- The name of the canceled file., dynamic type- The type of the canceled file., dynamic size- The size of the canceled file., int index- The index of the canceled file., dynamic status- The status of the uploaded file. Whether there was an error or success.
UploadErroredevent FileUploadUploadErroredEventHandlerThis event is triggered when during the file upload process something happens and upload fails.FileUploadUploadErroredEventArgs
OnUploadPausedEventCallback<Event>This event is triggered when a file upload operation is paused.dynamic filename- The name of the paused file., dynamic type- The type of the paused file., dynamic size- The size of the paused file., int index- The index of the paused file.
UploadPausedevent FileUploadUploadPausedEventHandlerThis event is triggered when a file upload operation is paused.FileUploadUploadPausedEventArgs
OnUploadStartedEventCallback<Event>This event is triggered when a file upload operation is started.dynamic filename- The name of the file that is being uploaded., dynamic type- The type of the file that is being uploaded., dynamic size- The size of the file that is being uploaded., int index- The index of the file that is being uploaded.
UploadStartedevent FileUploadUploadStartedEventHandlerThis event is triggered when a file upload operation is started.FileUploadUploadStartedEventArgs
OnValidationErrorEventCallback<Event>This event is triggered if the validation of a user defined 'validateFile' callback fails.dynamic filename- The name of the file which validation has failed., dynamic type- The type of the file which validation has failed., dynamic size- The size of the file which validation has failed.
ValidationErroredevent FileUploadValidationErroredEventHandlerThis event is triggered if the validation of a user defined 'validateFile' callback fails.FileUploadValidationErroredEventArgs