Skip to main content

Upload Modes

  • 5 minutes to read

ASPxUploadControl allows you to use the ASPxUploadControl.UploadMode property to choose from two upload modes (Standard and Advanced). You can also set the property to Auto to select the upload mode automatically.

Standard Upload Mode

Set the ASPxUploadControl.UploadMode property to UploadControlUploadMode.Standard to enable Standard Upload Mode. You must also set the FileManagerUploadAdvancedModeSettings.EnableMultiSelect and FileManagerUploadAdvancedModeSettings.EnableDragAndDrop properties to false.

This is a standard FileUpload-based upload mode in which the file is sent to the server in a single request, and is cached in its entirety in the server memory. This mode works well with small files and is not suitable for uploading large files (such as 1GB files). The ASP.NET worker process has a virtual address space of 2GB. However, the ASP.NET worker process only uses a little more than 1GB because of ASP.NET health monitoring and memory fragmentation.

Additionally, ASPxUploadControl requires memory for upload progress visualization. Therefore, the actual maximum size of a file that can be uploaded in Standard Upload Mode with upload progress visualization enabled (the ASPxUploadControl.ShowProgressPanel property is set to true) is about 2GB/3 = 633MB.

When you allow large file uploads in this mode, it also requires that you increase the Request length limit (the Web.Config file’s maxRequestLength configuration setting), which is not protected against denial-of-service (DoS) attacks caused by users who post large files to the server.

Note

In Standard Upload Mode, a file upload is initiated automatically on the next postback.

Advanced Upload Mode

Set the ASPxUploadControl.UploadMode property to UploadControlUploadMode.Advanced to enable Advanced Upload Mode. To access and customize the settings that relate to Advanced Upload Mode, use the ASPxUploadControl.AdvancedModeSettings property.

In this mode, the uploaded file is sent to the server in small packets (one at a time). The packets are saved into a temporary file, which has the .tmp extension, until upload is complete. You can use the UploadAdvancedModeSettings.TemporaryFolder property to specify the folder containing temporary files.

Note that files are deleted from the temporary folder in the following cases:

  • Once a file is uploaded.
  • After the pre-defined time has elapsed. This time period is defined by the UploadAdvancedModeSettings.UploadingExpirationTime property and is set to 6 hours (the default setting). Note that the file is removed only if the server has not been restarted during this time. If the server is rebooted during this time, the file will be removed in 6 days.

Advanced Upload Mode implementation is based on HTML5 technology. If HTML5 support is not available in an end-user browser, this mode uses Microsoft Silverlight technology. If HTML5 is not supported and Silverlight is not installed or is disabled, a message with a link to download Silverlight is displayed instead of ASPxUploadControl.

Advanced Upload Mode has the following benefits:

  • Uploading Large Files

    Since a file is sent in small packets, users can upload large files without using a large amount of web server memory. In this case each packet is sent separately, so after the initial packet is sent, the next packet is not sent until the previous packet frees up memory resources. The default packet size is 200 KB. To change the packet size, use the UploadAdvancedModeSettings.PacketSize property. You can also use the UploadAdvancedModeSettings.TemporaryFolder property to specify the server folder to which each uploaded file is saved (the default path is “~\App_Data\UploadTemp").

    After the file upload is complete, you can access the uploaded file as a file stream. To do this, handle the ASPxUploadControl.FilesUploadComplete event (or the server-side ASPxUploadControl.FileUploadComplete event) and use the UploadedFile.FileContent property of the related UploadedFile object.

    protected void ASPxUploadControl1_FileUploadComplete(object sender, FileUploadCompleteEventArgs e) {
            using(Stream stream = e.UploadedFile.FileContent)  {
                stream.Read(...);
            }
        }
    

    Note

    When you use Advanced Upload Mode, you must operate the uploaded file’s stream within the using statement (the Using statement in Visual Basic).

    Refer to the following topic to learn more about how to customize ASPxUploadControl for large file uploads: Uploading Large Files.

  • Preventing Denial-of-Service (DoS) Attacks

    In Advanced Upload Mode, you are not required to set the Request length limit to a large value (controlled by the maxRequestLength configuration setting within Web.Config), since large files are sent in small chunks. A large maxRequestLength value makes a website more vulnerable to denial-of-service attacks caused when users post many large files to the server. Thus, Advanced Upload Mode allows you to keep the Request length limit reasonably small - to prevent potential DoS attacks.

  • Client-Side Validation

    ASPxUploadControl uses Microsoft Silverlight technology to validate the file size and file extension directly on the client side, without sending files to the server. This prevents unnecessary traffic to the web server. Client validation is invoked automatically if the UploadControlValidationSettings.MaxFileSize or UploadControlValidationSettings.AllowedFileExtensions property is defined. After a file has passed client-side validation, the ASPxUploadControl also performs a server-side validation check for extra protection.

  • Progress Indication in Medium Trust

    With Advanced Upload Mode, the functionality of the upload progress indicator (controlled by the ASPxUploadControl.ShowProgressPanel property) works well in web environments that only allow medium trust. In contrast to Standard Upload Mode (in which the current progress is not updated until file upload is complete), the current progress indicator is updated after each small file packet is uploaded.

  • Multi-File Selection in File Open Dialog

    In Advanced Upload Mode, ASPxUploadControl supports the multi-file selection capability, which allows users to choose multiple files to upload in a single file open dialog. Refer to the following topic to learn more: Multi-File Selection.

Note

In Advanced Upload Mode, a file upload is not initiated automatically on the next postback.

Automatic Upload Mode Selection

Automatic Upload Mode selection is enabled if the ASPxUploadControl.UploadMode property is set to UploadControlUploadMode.Auto.

In this case, ASPxUploadControl uses HTML5 technology in Advanced Upload Mode. If it is unavailable, Silverlight technology is used in Advanced Upload Mode. If Silverlight is unavailable, the upload control works in Standard Upload Mode.