Skip to main content

ASPxClientUploadControl.GetSelectedFiles Method

Returns files selected for uploading within the specified file input.

Declaration

GetSelectedFiles(
    inputIndex?: number
): ASPxClientUploadControlFile[]

Parameters

Name Type Description
inputIndex number

A file input‘s index. Default value is “0”.

Returns

Type Description
ASPxClientUploadControlFile[]

An array of files selected for uploading.

Remarks

Note that full information about the selected file is available only if the upload control is in advanced mode (ASPxUploadControl.UploadMode is set to “Advanced” or “Auto” for a user’s browser that supports HTML5). The control returns null if you use the Microsoft Silverlight plug-in and the browser does not support HTML5.

In standard mode (ASPxUploadControl.UploadMode is set to “Standard”), the returned object provides only the ASPxClientUploadControlFile.name property, while the ASPxClientUploadControlFile.size property is -1 and the ASPxClientUploadControlFile.sourceFileObject property is null.

var items = uploadControl.GetSelectedFiles();
var secondName = items[1].name;

Example

The following example shows how to disable users from uploading files without extension on the client side.

function OnTextChanged() {
    var filesForUploading = uploadControl.GetSelectedFiles();
    if (filesForUploading) {
        var allFilesContainExtension = true;
        for (var i = 0; i < filesForUploading.length; i++) {
            var currentFileName = filesForUploading[i].name;
            if (currentFileName == currentFileName.split('.').pop()) {
                allFilesContainExtension = false;
                break;
            }
        }
        if (!allFilesContainExtension) {
            alert("Only files with extentions can be uploaded");
            uploadControl.ClearText();
        }
    }
}
See Also