ASPxFileManager.FileUploading Event
Fires on the server side before a file is uploaded, and allows you to cancel the action.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Event Data
The FileUploading event's data class is FileManagerFileUploadEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets a value indicating whether the action that raised the event should be canceled. Inherited from FileManagerActionEventArgsBase. |
ErrorText | Gets or sets a text for the explanatory message. Inherited from FileManagerActionEventArgsBase. |
File | Gets a file, related to the event. |
FileName | Gets or sets the name of a file selected to upload. |
InputStream | Gets a stream object that points to the uploaded file. |
OutputStream | Gets a stream object that points to the uploaded file. |
Remarks
Before each time a file is uploaded on the server side, the FileUploading event occurs, allowing you to cancel the file upload. The event parameter’s FileManagerFileUploadEventArgs.File property identifies the file that is being processed. To cancel the upload operation, set the FileManagerActionEventArgsBase.Cancel property to true
. In order to show the message, explaining the reason for the upload cancellation, specify the FileManagerActionEventArgsBase.ErrorText property.
Example
The code below allows end-users to upload only mp3 files to the “Music mp3” folder.
protected void ASPxFileManager1_FileUploading(object source, DevExpress.Web.FileManagerFileUploadEventArgs e) {
if (e.File.Folder.FullName == "Files\\Music mp3")
if (e.File.Extension != ".mp3") {
e.Cancel = true;
e.ErrorText = "You can only upload mp3 files to this folder";
}
}