Limiting the number and size of items

Home > Basic examples > Example 08

Explanation

You can set limits on the number of files to be uploaded, individual size, and total size.

If no setting is made, no restriction is made by default. (Does not mean unlimited size upload support.)

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

// Returning the number of files allowed. If there is no limit, -1 is returned.
var maxCount = dx.getMaxFileCount();

// Setting up to allow a total of 5 files, excluding virtual files. 
dx.setMaxFileCount(5, false);

// Returning the size of the entire files that is allowed. If there is no limit, -1 is returned.
var maxTotalSize = dx.getMaxTotalSize();

// Setting the total size of the allowed files to 100MB, excluding virtual files. 
dx.setMaxTotalSize(104857600, false);

// Returning the maximum size of individual files. If there is no limit, -1 is returned.
var maxSize = dx.getMaxFileSize();

// Setting the maximum size of individual files to 10MB. 
dx.setMaxFileSize(10485760);

// Returning the minimum size of individual files. If there is no limit, -1 is returned.
var minSize = dx.getMinFileSize();

// Setting the minimum size of individual files to 1MB. 
dx.setMinFileSize(1048576);

Example

You can limit the total number of files. If the value is -1, no restriction is made.
Even if you do not limit the total number of files, if you have a large number of files, you can use the memory too much, and the components may be slower depending on the PC specification.
For reliable service operation, it is recommended that the total number of files be limited (relatively small).

You can limit the size of the entire file. If the value is -1, no restriction is made.
Even if the size of the whole file is not limited, it can be restricted by the server when the size of the transmission data (file + other information) exceeds 2 GB.
It is recommended that the total file size be limited (relatively low) for reliable service operation except for special purposes.

You can limit the maximum of individual file sizes. If the value is -1, no restriction is made.
Even if the size of the individual files is not limited, the size of the transferred data (file + other information) exceeding 2 GB may be limited by the server.
It is recommended that the individual file sizes be limited (relatively low) for stable service operation except for special purposes.

You can limit the minimum value of individual file sizes. If the value is -1, no restriction is made.