Limiting file extensions

Home > Basic examples > Example 09

Explanation

Only files with specific extensions can be allowed (net filter) or vice versa (inverse filter). You can also set whether to add files without an extension. In general, only net filters are used to increase security.

Virtual files are not subject to extension filtering.

var dx = dx5.get("component-id");

// If false, returns information about net filter setting. If true, returns information about inverse filter setting. 
var filtered = dx.getExtensionFilter(false);

// Only allow *.jpg, *.jpeg, *.gif, *.bmp, *.txt.
dx.setExtensionFilter("*.jpg;*.jpeg;*.gif;*.bmp;*.txt", false);

// *.jpg, *.jpeg, *.gif, *.bmp, *.txt are not allowed. 
dx.setExtensionFilter("*.jpg;*.jpeg;*.gif;*.bmp;*.txt", true);

// Do not allow files without extension.
dx.setAllowNoExtension(false);

Example

You can decide whether to allow file registration without an extension.

The net filter allows you to register only files with the extensions specified in the filter.
ex) *.jpg;*.jpeg;*.gif;*.bmp;*.txt

The inverse filter makes it impossible to register a file with the extension specified in the filter.
ex) *.ppt;*.xls;*.html