restrictions.fileMask Property HTML5/Flash Uploader JavaScript

Supported technologies: Adobe FlashHTML 5

Gets or sets a file mask for files allowed for upload.

Syntax

JavaScript Initialize
$au.imageUploaderFlash({
    restrictions: {
        //...other params...
        fileMask: [],
        //...other params...
    }
})
Get/Set Value at Runtime
$au.imageUploaderFlash('uploaderID').restrictions().fileMask(value);
value = $au.imageUploaderFlash('uploaderID').restrictions().fileMask();

Property Value

Type: Array

A file mask for files allowed for upload. The property value contains array of filters. Each item consists of two elements:

  • Description string displayed in the drop-down filter list in the open file dialog.
  • List of file masks separated by semicolons. A file mask has the *.<extension name> format, where asterisk * is an arbitrary file name.

For instance, a filter can be set as follows: [["Images", "*.jpg;*.png"], [...]], where "Images" is a description, and "*.jpg;*.png" is a file mask.

Even if a user chooses files that do not meet FIleMask's requirements, Uploader sorts out the chosen files before adding them to the Upload Pane.

Note

In Flash Uploader a file mask with a long description can work incorrectly due to Firefox limitations. Thus, we recommend setting description as short as possible. For example, ["Documents", "*.txt;*.rtf;*.pdf;*.doc;*.docx;*.xls;*.xlsx"] works correctly but ["Documents (*.txt;*.rtf;*.pdf;*.doc;*.docx;*.xls;*.xlsx)", "*.txt;*.rtf;*.pdf;*.doc;*.docx;*.xls;*.xlsx"] does not.

Note

Due to browsers limitations, HTML5 Uploader ignores filter descriptions specified in settings and displays text strings predefined in a web browser. Even though descriptions are ignored, they are still required in parameters since Flash Uploader, which can be launched as a fallback option, supports them.

Note

Due to Firefox security features, HTML5 Uploader always adds *.* mask to the file filter in this browser and makes it selected by default.

Instead of specifying a double array, you can just set a string with the single mask. However it will be incompatible with Flash uploader.

Default value is [].

Remarks

When opening a File Open Dialog in HTML5, it is necessary to specify a filter as a set of MIME types rather than file masks. HTML5 Uploader converts most popular file masks to appropriate file types automatically, but some exotic file extensions are not supported. In this case, you can configure a mapping between a file mask and MIME type manually, using Aurigma.MimeMapping collection, as follows:

Aurigma.MimeMapping["*.smth"] = "application/vnd.aurigma-stuff";

Note, you should call this code before the uploader is initialized, for example, in the InitComplete event.

See Also

Reference

Manual