A newer version of this page is available. Switch to the current version.

ASPxUploadControl.SaveAs(String) Method

Obsolete. Saves the uploaded file specifying the full path on the server.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll


[Obsolete("Use the UploadedFiles[].SaveAs method instead.")]
public void SaveAs(
    string fileName
<Obsolete("Use the UploadedFiles[].SaveAs method instead.")>
Public Sub SaveAs(
    fileName As String


Name Type Description
fileName String

A String that specifies the full path to the location on the server to save the uploaded file.


Uploading the file specified on the client can be initiated either by the ASPxUploadControl's ASPxClientUploadControl.Upload client method, or automatically on the next round trip to the server. The SaveAs method can be used to save the uploaded file to a specific location on the server. Typically, the SaveAs method is called within the ASPxClientUploadControl.FileUploadComplete event's handler. Before calling the SaveAs method, it is recommended to test the FileUploadCompleteEventArgs.IsValid property, to verify whether the uploaded file passes the validation criteria, if any have been defined via the ASPxUploadControl.ValidationSettings property, or specific custom code.

The SaveAs method's parameter value represents the full path on the server where the uploaded file should be saved. This path can either be absolute (for instance, "C:/Documents/Image.jpg") or relate to the web application's folder (by using the MapPath method). When composing the saved file's path, you can define any custom name for the file or use the name obtained by the ASPxUploadControl.FileName property.


To be able to save the uploaded file, the ASP.NET application should have write access to the specified directory on the server. If the file full path is not indicated, the file will be saved to the current location. If the file with the specified name already exists, this file will be overwritten.

Note that the SaveAs method is not in effect if the file hasn't been uploaded to the server because of specific limitations defined within the web.config file's httpRuntime section; in particular, the maxRequestLength and executionTimeout attribute settings may affect file uploading. You can define the values of these attributes using the "Set Uploading Properties in web.config" dialog, available via the ASPxUploadControl's smart tag.


The following sample code demonstrates how to save the file specified within the ASPxUploadControl on the client. Before file saving, the FileUploadCompleteEventArgs.IsValid property is tested to verify whether the file passes the validation criteria defined via the ASPxUploadControl.ValidationSettings property. Note, that in order to compose the ASPxUploadControl.SaveAs method's parameter value, the System.Web.Hosting.HostingEnvironment.MapPath method and ASPxUploadControl.FileName property are used to specify the web application's Image folder as a location where the file should be saved and define the file's name, respectively.

<%@ Page Language="C#" %> 
<%@ Register Assembly="DevExpress.Web.v10.2, Version=, Culture=neutral, 
PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxUploadControl" TagPrefix="dxuc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">
 protected void Page_Load(object sender, EventArgs e) {

    protected void ASPxUploadControl1_FileUploadComplete(object sender, 
DevExpress.Web.FileUploadCompleteEventArgs e) {
        if (e.IsValid) {
            e.UploadedFile.SaveAs(MapPath("Images/" + e.UploadedFile.FileName));

<html xmlns="" >
<head runat="server">
    <title>How to use the ASPxUploadControl's SaveAs method</title>
    <form id="form1" runat="server">
See Also