- File Uploader initialization
- Single-file file uploader
- Multi-file file uploader
- Multi-purpose file uploader
- Passing a single file to a file uploader
- Pass multiple files to a file uploader
- Get current file uploader value
- Load new file or group
- Open the file uploader dialog
- On change, file uploader event
- On upload complete, file uploader event
- On dialog open
- Unsubscribe file uploader callbacks
File Uploader initialization
Initialize a file uploader.
This is a one-time initialization of file uploader instances on every element with the
role="uploadcare-uploader" attribute in a container specified by a selector or
DOM element. Works for both single-file and
multi-file file uploaders.
Returns an array of newly initialized file uploaders or an empty array in case no new instances were initialized.
uploadcare.initialize() method is called automatically unless the
manual start file uploader option is defined.
Single-file file uploaders
Get a single-upload file uploader instance for a given element.
uploadcare.SingleWidget() element argument can be a DOM element, jQuery object,
or CSS selector. If an argument is a CSS selector, the method returns only an
instance for the first matched element. To ensure you are getting the right
instance when dealing with multiple file uploaders on a page, select by id or pass a
DOM element to the method.
All file uploader options will be loaded from data-attribute of your element on a first file uploader initialization.
Passing an element with the
data-multiple attribute to
raises an error. A multi-upload file uploader should
be used instead.
Multi-file file uploaders
Get a multi-upload file uploader instance for a given element with the
The workflow is similar to single-upload file uploader. If an instance of the first encountered element is not a multi-upload file uploader, an error is raised.
Multi-purpose file uploaders
Get either single-upload or multi-upload file uploader instance depending on the passed
While the API for single-upload and multi-upload file uploaders is slightly different,
you can use this constructor when your code can work with both versions:
Pass a single file to a file uploader
Set a file instance as a value for a single-upload file uploader.
You can also use a file UUID or CDN link as a value:
null as a value clears the file uploader:
Pass multiple files to a file uploader
Set a group instance as a value for a multi-upload file uploader.
You can also set an array of file instances or UUIDs as a value for the multi-upload:
Or, just pass a valid file group identifier:
Get a current file uploader value
Get current file uploader value: file instance, group instance or
Load a new file or group
Load a new file or group instance from the
value attribute of your
update the object info. You will get a UUID or CDN link.
Open a file uploader dialog
Open the dialog of a specific file uploader and get its instance. Returns a dialog API.
tab defines a name of the tab opened by default.
On change, file uploader event
Provides you with the ability to do something after a new file is selected. An instance is passed to the callback: a file for single-upload file uploaders or a file group for multi-upload file uploaders. The instance may or may not be uploaded.
On upload complete, file uploader event
Provides you with the ability to do something after a file is uploaded and ready. The callback is passed an info object: a file info for single-upload file uploaders or a file group info for multi-upload file uploaders.
On dialog open, file uploader event
Provides you with the ability to do something on file uploader dialog open. Works with a user click or the widget.openDialog() call. Works only when the system dialog option is disabled.
Unsubscribe file uploader callbacks
Allows you to unsubscribe any file uploader callback: