Check if the upload is required.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// check if the upload is required
var isRequired = fileUpload.required;
Set the upload control as required or not required.
Set to true
to make the control required, or false
to make it not required.
This method affects the client-side behavior only and does not impact the server-side validation.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// set the upload control as required
fileUpload.required = true;
Check if the field content is valid:
A Promise that resolves to a ValidationInfo object. The object contains the validation status (valStatus
), the validation message (valMessage
), and the validation type (valType
).
// Get the control by its element GUID and check its validity
const validityResult = await ix.api.dom.getControl("<FILEUPLOAD-GUID>").checkValidity();
// Example of `validityResult` when the field is required but not filled:
ValidationInfo {
valStatus: false,
valMessage: 'Please make a selection',
valType: 'required'
}
Get detailed information about the uploaded files.
An array of objects containing the file ID, the file mimetype, the file name, a boolean indicating if the file is new and the HTML element.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// get detailed information about the uploaded files
var filesInfo = fileUpload.getFilesInfo();
// Example output:
filesInfo = [
{
id: "1",
mimeType: "image/png",
name: "image.png",
new: false,
element: HTMLElement
},
{
id: "2",
mimeType: "application/pdf",
name: "document.pdf",
new: true,
element: HTMLElement
}
]
Gets the image editor associated with the specified file ID from the file upload control.
The ID of the file.
The image editor corresponding to the given file ID.
An image editor is only available for image files that have already been uploaded and only if at least one editor is activated in the file upload control options.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// determine the file ID you want to get the image editor for
// you can use the `getValue(true)` or `getFilesInfo()` method to get the ID of an file
// in this example we use the first file
var fileId = fileUpload.getFilesInfo()[0].id;
// get the image editor with the given file id
var imageEditor = fileUpload.getImageEditor(fileId);
Gets all image editors within the file upload control.
An image editor is only available for image files that have already been uploaded and only if at least one editor is activated in the file upload control options.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// get all image editors within the file upload control
var imageEditors = fileUpload.getImageEditors();
Get the number of selected but not uploaded files.
// get the file upload control
var fileUpload = ix.api.dom.getControl("<FILEUPLOAD-GUID>");
// get the number of selected but not uploaded files
var numberOfFilesToUpload = fileUpload.getNumberOfFilesToUpload();
Retrieves the current value of the file upload control.
This method returns either an array of file names or detailed information about the files, depending on the verbose
parameter.
Optional
verbose: booleanOptional.
true
, the method returns an object containing detailed information about the files.false
or omitted, the method returns an array of file names.The value of the control.
verbose
is true, the return value is an object containing detailed information about the files. See "getFilesInfo" method for more info.// Get the control by its element GUID and retrieve the value
const value = ix.api.dom.getControl("<ELEMENT-GUID>").getValue());
Represents a file upload control.
The File Selection is a control that allows users to select files from their local system, upload them to the server and make them available for download. It provides an interface for file selection, progress indication and error handling.
The control supports multiple file selection, drag-and-drop file selection, and provides a callback for successful uploads. It also handles server-side validation and provides feedback to the user.