Skip to main content
A newer version of this page is available. .
Tab

ASPxUploadControl.UploadedFiles Property

Provides access to an array whose entries correspond to the ASPxUploadControl’s file input elements and contain information on the uploaded files, if any.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

public UploadedFile[] UploadedFiles { get; }

Property Value

Type Description
UploadedFile[]

An array of UploadedFile objects associated with file input elements.

Remarks

In order to upload a file, an end-user should specify it within a file input element. The total amount of available file input elements is controlled via the ASPxUploadControl.FileInputCount property. This amount can also be dynamically changed by end-users on the client, if the ASPxUploadControl.ShowAddRemoveButtons property is enabled. In this case, the ASPxUploadControl.FileInputCount property value is synchronized with actual number of file input elements after the most recent postback to the server.

The UploadedFiles property is used to access an array of automatically generated UploadedFile objects which are associated with file input elements. For each file input element, there is the corresponding UploadedFile entry within the UploadedFiles array. An individual UploadedFile object can be accessed via its index, which corresponds to the associated file input element’s visual index (it is assumed that file input element indexes are zero-based). So, you can access the first file input element’s associated UploadedFile object as ASPxUploadControl1.UploadedFile[0], and the last file input element’s associated UploadedFile object as ASPxUploadControl1.UploadedFiles[ASPxUploadControl1.FileInputCount - 1], and so on.

Example

This sample demonstrates how files selected within the ASPxUploadControl can be uploaded via either postback or callback, and how the uploaded files can be saved on the server side by using the FilesUploadComplete event.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxUploadControl;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e){

    }

    protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FilesUploadCompleteEventArgs e){
        // Intentionally pauses server-side processing to demonstrate the Loading Panel or Progress Panel functionality
        System.Threading.Thread.Sleep(2000);

        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);
                    //file.SaveAs(fileName, true);//OnLine Demo Restriction
                }
            }
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the UploadedFiles property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also