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

Upload Modes

  • 5 minutes to read

The BootstrapUploadControl provides the capability to choose from two upload modes (Standard and Advanced), which can be specified using the ASPxUploadControl.UploadMode property. You can also set the property to Auto to select the upload mode automatically.

Standard Upload Mode

Setting the ASPxUploadControl.UploadMode property to UploadControlUploadMode.Standard enables the Standard Upload Mode. This is a standard FileUpload-based mode in which the uploaded 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 (1GB+). The ASP.NET worker process has a virtual address space of 2GB. However, it only uses a little more than 1 GB because of ASP.NET health monitoring and memory fragmentation (see the Cannot Upload Large Files… topic on the Microsoft website for more details).

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

You need to increase the Request length limit (using the Web.Config file’s maxRequestLength configuration setting), which does not protect against denial-of-service (DoS) attacks caused by users who post large files to the server, to allow large file uploads in this mode.

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 the Advanced Upload Mode. You can access and customize the settings that relate to the Advanced Upload Mode using the BootstrapUploadControl.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 .tmp file until the upload is complete. You can use the UploadAdvancedModeSettings.TemporaryFolder property to specify the folder for temporary files.

Note that files are deleted from this folder in the following cases.

  • Once a file is uploaded.
  • After the pre-defined time has elapsed (normally twenty minutes).

The file might also be removed if the server shuts down using the stop command. If the server shuts down abnormally, the temporary file is not removed. However, it is removed later when the server is restarts.

The Advanced Upload Mode implementation is based on HTML5 technology and has the following benefits:

  • Uploading Large Files

    Sending a file in small packets allows end-users to upload large files without using a large amount of web server memory because only one packet per file is stored in memory at a time. The UploadAdvancedModeSettings.PacketSize property can customize the packet size (which by default is 200 KB). The server folder to which each uploaded file is saved can also be specified via the UploadAdvancedModeSettings.TemporaryFolder property (the default path is “~\App_Data\UploadTemp").

    After the file upload is complete, you can access the uploaded file as a file stream using the UploadedFile.FileContent property of the related UploadedFile object while handling the ASPxUploadControl.FilesUploadComplete event or the server-side ASPxUploadControl.FileUploadComplete event.

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

    Note

    When using the Advanced Upload Mode, operating the uploaded file’s stream within the using statement (the Using statement in Visual Basic) is required.

  • Preventing Denial-of-Service (DoS) Attacks

    In the Advanced Upload Mode, you are not required to define a large value for the Request length limit (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 that can be caused by end-users posting many large files to the server. The Advanced Upload Mode allows you to keep the Request length limit reasonably small, preventing potential DoS attacks.

  • Client-Side Validation

    In the Advanced Upload Mode, the Upload Control can 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 Upload Control also performs a server-side validation check that provides extra protection.

  • Progress Indication in Medium Trust

    With the 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 the Standard Upload Mode (in which the current progress does not update 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 the Advanced Upload Mode, the Upload Control supports the multi-file selection capability, allowing end-users to choose multiple files to upload in a single file open dialog. Refer to the Multi-File Selection topic to learn more.

Important

The ASPxUploadControl.FileUploadComplete event is not raised for individual files if multiple files are uploaded in the Advanced mode.

Automatic Upload Mode Selection

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

In this case, the Upload Control uses the HTML5 technology (Advanced Upload Mode). If it is unavailable, the upload control works in the Standard Upload Mode.