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

elenapeskova/how-to-save-uploaded-files-by-handling-the-filesuploadcomplete-server-event-e3067

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

[Run Online]

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

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

Languages

  • ASP.NET 71.8%
  • C# 28.2%