Table of Contents

FileUploader Class

Definition

Namespace
GleamTech.FileUltimate.AspNet.UI
Assembly
GleamTech.FileUltimate.dll

The component for uploading files and folders.

public sealed class FileUploader : StatefulComponent<FileUploaderState>
Inheritance
Component
StatefulComponent
StatefulComponent<FileUploaderState>
FileUploader

Examples

@using GleamTech.AspNet.Mvc
@using GleamTech.FileUltimate.AspNet.UI

<!DOCTYPE html>
@{
    var fileUploader = new FileUploader
    {
        Width = 600,
        Height = 300,
        Resizable = true,
        UploadLocation = "~/App_Data/Uploads"
    };
}
<html>
<head>
    <title>File Uploader</title>
    @this.RenderHead(fileUploader)
</head>
<body>
    @this.RenderBody(fileUploader)
</body>
</html>
@Imports GleamTech.AspNet.Mvc
@Imports GleamTech.FileUltimate.AspNet.UI

<!DOCTYPE html>
@Code
    Dim fileUploader = New FileUploader() With {
        .Width = 600,
        .Height = 300,
        .Resizable = True,
        .UploadLocation = "~/App_Data/Uploads"
    }
End Code
<html>
    <head>
        <title>File Uploader</title>
        @Me.RenderHead(fileUploader)
    </head>
    <body>
        @Me.RenderBody(fileUploader)
    </body>
</html>

Note that for ASP.NET Core, you also need to add and register GleamTech in Startup.cs, please see .

Constructors

FileUploader()

Initializes a new instance of the FileUploader class.

FileUploader(FileUltimateWebConfiguration)

Initializes a new instance of the FileUploader class with custom web configuration.

Properties

AllowedFileTypes

Gets or sets the file patterns that are allowed to be uploaded. If not set, any file type is allowed ("*").

DeniedFileTypes take precedence over AllowedFileTypes. For instance, when AllowedFileTypes is set to "*.jpg|*.gif" and DeniedFileTypes is set to "*.gif", only "*.jpg" will be allowed.

When combining patterns in string representation (e.g. when setting in markup), they should be separated by vertical bar (|).

In a pattern, you can use these wildcards:

  • * matches zero or more characters.
  • ? matches exactly one character.

Some pattern examples:

  • *.* matches files with any extension (does not match files without an extension)
  • *.jpg matches files only with jpg extension
  • picture*.jpg matches files only with jpg extension and which names start with 'picture'
  • picture.* matches files with any extension and which names start with 'picture'
  • picture matches files with no extension and which names are exactly 'picture'
  • *.jp* matches files like 'picture.jpg', 'otherpicture.jpe', 'somepicture.jpeg' etc.
  • *.jp? matches files like 'picture.jpg', 'otherpicture.jpe' etc.
  • picture?.jpg matches files like 'picture1.jpg', 'picture2.jpg', 'pictures.jpg' etc.
AutoClose

Gets or sets a value that specifies whether FileUploader closes itself automatically when the upload is successful. The default is false. Note that auto-closing will be canceled if one or more items fails, this allows the user to click "status reason" and examine the problem.

AutoStart

Gets or sets a value that specifies whether FileUploader starts uploading automatically after any files are added to the upload queue (user does not need to click "Upload" button). The default is false.

ChunkSize

Gets or sets the chunk size used in chunked uploading mode. The default is usually 28.6 MB (or 4MB for ASP.NET Classic before 4.5). The default and highest value is determined from Web.config. For ASP.NET Core and ASP.NET Classic 4.5+, it is determined only from system.webServer/requestLimits/maxAllowedContentLength property in Web.Config. For ASP.NET Classic before 4.5, it is determined additionally from system.web/httpRuntime/maxRequestLength property in Web.Config.

With chunked uploading mode, which is the default mode on modern browsers, file is split into chunks and chunks are uploaded one by one, and then chunks are reassembled back on the server. The reason for using chunked uploading when possible, is to overcome server's default request limitations. By using chunking, normally you don't need to change any settings to allow uploading of very large files out of the box. Currently all upload methods except Html4 uses chunked uploading (Html5 or Flash or Silverlight), this is because Html4 cannot split into chunks and can only send the whole file in a single request (multipart/form-data).

Information on various request size limits:

  • IIS by default has 30000000 (28.6 MB) request size limit, controlled by system.webServer/requestLimits/maxAllowedContentLength property in Web.Config, in bytes, maximum value is 4294967295 (4 GB). However maximum value is 2147483647 (2 GB) when the application is running under the NET 4.5 Integrated Pipeline Application Pool. This setting effects FileUploader, as it is an IIS setting, FileUploader cannot automatically override it.
  • ASP.NET Core by default has 30000000 (28.6 MB) request size limit, controlled by IHttpMaxRequestBodySizeFeature.MaxRequestBodySize property in code, in bytes, maximum value is unlimited if null. This setting does not effect FileUploader, i.e FileUploader can automatically override it.
  • ASP.NET Classic by default has 4096 (4 MB) request size limit, controlled by system.web/httpRuntime/maxRequestLength property in Web.Config, in kilobytes, maximum value is 2097151 (2 GB). This setting effects FileUploader only if you are running under server runtime lower than ASP.NET Classic 4.5 version, i.e when FileUploader cannot automatically override it.
ClientEvents

Gets or sets the client-side event handlers.

CustomParameters

Gets or sets the custom parameters for this uploader instance, to send along with the upload queue. These custom parameters can be retrieved in server-side events, for example to take an action depending on the parameters.

The key of the dictionary is of string type. The value the dictionary is of object type which means you can set any value that is JSON serializable. For values, it's recommended to use primitive types like string, bool, int etc.

DeniedFileTypes

Gets or sets specifies the file patterns that are denied to be uploaded. If not set, no file type is denied ("").

DeniedFileTypes take precedence over AllowedFileTypes. For instance, when AllowedFileTypes is set to "*.jpg|*.gif" and DeniedFileTypes is set to "*.gif", only "*.jpg" will be allowed.

When combining patterns in string representation (e.g. when setting in markup), they should be separated by vertical bar (|).

In a pattern, you can use these wildcards:

  • * matches zero or more characters.
  • ? matches exactly one character.

Some pattern examples:

  • *.* matches files with any extension (does not match files without an extension)
  • *.jpg matches files only with jpg extension
  • picture*.jpg matches files only with jpg extension and which names start with 'picture'
  • picture.* matches files with any extension and which names start with 'picture'
  • picture matches files with no extension and which names are exactly 'picture'
  • *.jp* matches files like 'picture.jpg', 'otherpicture.jpe', 'somepicture.jpeg' etc.
  • *.jp? matches files like 'picture.jpg', 'otherpicture.jpe' etc.
  • picture?.jpg matches files like 'picture1.jpg', 'picture2.jpg', 'pictures.jpg' etc.
DisplayLanguage

Gets or sets the display (user interface) language of the file uploader. It is usually set as the two-letter language names like en, de, fr etc. as the bundled languages are usually for general language names. However it can be also set to specific cultures like en-US, de-DE, fr-FR etc. For example, if the property is set to a specific culture like de-CH (German in Switzerland), the component will first look for the language file FileUltimate-de-CH.xml and if the file is not found, it will load the general (fallback) language file of that culture which is FileUltimate-de.xml. If not set, the language file which matches the current UICulture of the host application will be loaded. If there is no language file which matches the current UICulture or its fallback, then the default language file FileUltimate.xml is loaded.

FormatLanguage

Gets or sets the format language of the file uploader. Format language is used for the number and date/time formats. It is usually set as the specific cultures like en-US, de-DE, fr-FR etc. If not set, the current Culture of the host application will be used.

MaxFileCount

Gets or sets the maximum allowed file count to upload. If not set, there will be no size limit for upload. 0 (zero) also means unlimited.

MaxFileSize

Gets or sets the maximum allowed file size to upload. If not set, there will be no size limit for upload. 0 (zero) also means unlimited.

Methods

Gets or sets a comma separated upload methods in priority order. The default is "Html5, Silverlight, Flash, Html4". It's not recommended to change this property as the default order offers the best upload experience.

ShowFileExtensions

Gets or sets a value that specifies whether the extension part of the file names should be be displayed. The default is false. When this set to true, the file extension will be also editable in dialog boxes when user is prompted (eg. on Rename).

UploadLocation

Gets or sets the file system location for uploading files to. The default value is "~/App_Data/Uploads".

This property can be set to:

  • A plain string which contains a physical/virtual path
    (e.g. "c:\SomeFolder", "/SomeFolder", "~/SomeFolder").

    This is parsed as GleamTech.FileSystems.Physical.PhysicalLocation.

    Note that virtual paths can only be resolved in a web application
    and on Linux paths starting with "/" are physical paths and not virtual paths.

  • A GleamTech.FileSystems.Location instance created with one of the builtin location providers
    (e.g. GleamTech.FileSystems.Physical.PhysicalLocation, GleamTech.FileSystems.AzureBlob.AzureBlobLocation, GleamTech.FileSystems.AmazonS3.AmazonS3Location, GleamTech.FileSystems.Archive.ArchiveLocation).

    You can also override GleamTech.FileSystems.Location base class to implement your custom location provider.

  • A provider string which defines a specific location provider
    (e.g. "Type=Physical; Path=c:\SomeFolder").

UploadProviderType

Gets or sets the upload provider type which provides a custom way of handling uploaded files. If not set, by default DefaultUploadProvider will be used which will handle uploads according to UploadLocation property. This class should implement IUploadProvider interface and should have a parameterless constructor so that it can be instantiated internally when necessary.

ViewLayout

Gets or sets the initial view layout type for listing files and folders that added to the upload queue. The default is LargeIcons. Possible values are ExtraLargeIcons, LargeIcons, MediumIcons, SmallIcons, Details and Tiles.

Methods

GetCssFileTags()
GetJsFileTags()
GetMetaTags()
WriteProperties(PropertyWriter)

Events

Failed

Occurs when a queue for one or more items fails in file uploader.

ItemFailed

Occurs when an item of a queue fails in file uploader.

ItemUploaded

Occurs after user uploads an item of a queue in file uploader.

ItemUploading

Occurs before user uploads an item of a queue in file uploader.

Uploaded

Occurs after user uploads a queue for one or more items in file uploader.

Uploading

Occurs before user uploads a queue for one or more items in file uploader.