To use the multiple file widget, you must add a data-attribute of multiple= "true"
. If you also want to include the "Remove" links as shown below, add a data-attribute of remove-links="true"
. You can optionallly set the maximum number of files allowed (defaults to 20) using data-max-files
.
When the uploader is configured for multiple file, the hidden input will be replaced with an "Add Files" button. The button text can be configured using the data-button-text
data-attribute.
There are two methods to access the uploaded files - respond to the javascript event or read the form parameters on your server.
fileUploadSuccess
event is fired. The file list is available on the event
e.detail.files
. You can listen for the event like this: []
appended to the name. Most server side languages will parse this format into an array.
params.require(:user).permit(avatar_url: [])
params["user"]["avatar_url"]
The button fires a buttonCreated
javascript event when it is available to customize. The button id is available via e.detail.id
. Listen for the javascript event and replace the css with your own.