Skip to content

Latest commit

 

History

47 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

3 stars

Watchers

53 watching

Forks

Used by

Contributors

Languages