UploadElement
<vaadin-upload> is a Web Component for uploading multiple files with drag and drop support.
Example:
<vaadin-upload></vaadin-upload>Styling
The following shadow DOM parts are available for styling:
| Part name | Description |
|---|---|
primary-buttons | Upload container |
drop-label | Element wrapping drop label and icon |
The following state attributes are available for styling:
| Attribute | Description |
|---|---|
disabled | Set when the element is disabled |
nodrop | Set when drag and drop is disabled (e.g., on touch devices) |
dragover | Set when the file is being dragged over the element |
dragover-valid | Set when the dragged file is valid with maxFiles and accept criteria |
max-files-reached | Set when maximum number of files that the user is allowed to add has been reached |
The following custom CSS properties are available for styling:
| Custom CSS property |
|---|
--vaadin-upload-background |
--vaadin-upload-border-color |
--vaadin-upload-border-radius |
--vaadin-upload-border-width |
--vaadin-upload-drop-label-color |
--vaadin-upload-drop-label-font-size |
--vaadin-upload-drop-label-font-weight |
--vaadin-upload-drop-label-gap |
--vaadin-upload-drop-label-line-height |
--vaadin-upload-file-border-radius |
--vaadin-upload-file-button-background |
--vaadin-upload-file-button-border-color |
--vaadin-upload-file-button-border-radius |
--vaadin-upload-file-button-border-width |
--vaadin-upload-file-button-padding |
--vaadin-upload-file-button-text-color |
--vaadin-upload-file-done-color |
--vaadin-upload-file-error-color |
--vaadin-upload-file-error-font-size |
--vaadin-upload-file-error-font-weight |
--vaadin-upload-file-error-line-height |
--vaadin-upload-file-gap |
--vaadin-upload-file-list-divider-color |
--vaadin-upload-file-list-divider-width |
--vaadin-upload-file-name-color |
--vaadin-upload-file-name-font-size |
--vaadin-upload-file-name-font-weight |
--vaadin-upload-file-name-line-height |
--vaadin-upload-file-padding |
--vaadin-upload-file-status-color |
--vaadin-upload-file-status-font-size |
--vaadin-upload-file-status-font-weight |
--vaadin-upload-file-status-line-height |
--vaadin-upload-file-warning-color |
--vaadin-upload-gap |
--vaadin-upload-icon-color |
--vaadin-upload-padding |
See Styling Components documentation.
Properties
Specifies the types of files that the server accepts. Syntax: a comma-separated list of MIME type patterns (wildcards are allowed) or file extensions. Notice that MIME types are widely supported, while file extensions are only implemented in certain browsers, so avoid using it. Example: accept="video/*,image/tiff" or accept=".pdf,audio/mp3"
The array of files being processed, or already uploaded.
Specifies the 'name' property at Content-Disposition for multipart uploads. This property is ignored when uploadFormat is 'raw'.
Specifies the maximum number of files that can be uploaded simultaneously. This helps prevent browser performance degradation and XHR limitations when uploading large numbers of files. Files exceeding this limit will be queued and uploaded as active uploads complete.
Specifies the maximum file size in bytes allowed to upload. Notice that it is a client-side constraint, which will be checked before sending the request. Obviously you need to do the same validation in the server-side and be sure that they are aligned.
Specifies if the maximum number of files have been uploaded
Define whether the element supports dropping files on it for uploading. By default it's enabled in desktop and disabled in touch devices because mobile devices do not support drag events in general. Setting it false means that drop is enabled even in touch-devices, and true disables drop in all devices.
Specifies the upload format to use when sending files to the server.
Set the withCredentials flag on the request.
Functions
Triggers the upload of any files that are not completed