Skip to content

Upload files on a callback and postback and handle the upload control's FilesUploadComplete event to save the files on the server.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-web-forms-upload-control-save-files-on-the-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upload Control for ASP.NET Web Forms - How to save uploaded files on the server

This example demonstrates how to upload files on a callback and postback and handle the upload control's FilesUploadComplete event to save the files on the server.

Upload files to the server

Overview

Create the Upload control and add two buttons to the page. To upload files on a callback or postback, enable or disable the buttons' AutoPostBack properties. When a user selects a file and clicks a button, the selected file is uploaded to the server.

To save the file to a specific location on the server, handle the upload control's FilesUploadComplete event and specify the file's name and path in the handler.

protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) {
    // ...
    ASPxUploadControl uploadControl = sender as ASPxUploadControl;
    if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0) {
        for (int i = 0; i < uploadControl.UploadedFiles.Length; i++) {
            UploadedFile file = uploadControl.UploadedFiles[i];
            if (file.FileName != "") {
                string fileName = string.Format("{0}{1}", MapPath("~/Images/"), file.FileName);
            }
        }
    }
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Upload files on a callback and postback and handle the upload control's FilesUploadComplete event to save the files on the server.

Topics

Resources

License

Stars

Watchers

Forks