Skip to main content
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.v23.2.dll

NuGet Package: DevExpress.Web

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).

Note

We recommend that you use the UploadedFiles property only in the FileUploadComplete and FilesUploadComplete event handlers because this property may contain invalid data outside these events.

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.

View Example

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 snippet (auto-collected from DevExpress Examples) contains a reference 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