mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-02-12 16:18:48 +00:00
20 lines
430 B
JavaScript
20 lines
430 B
JavaScript
/**
|
|
* Extracts a list of files from a dom event when it is triggered. Supports both input
|
|
* and drag and drop file uploads.
|
|
*
|
|
* @param event
|
|
* @returns {null}
|
|
*/
|
|
export function getFilesFromEvent(event) {
|
|
if (event.target?.files) {
|
|
// Files via the file upload input.
|
|
return event.target.files
|
|
}
|
|
|
|
if (event.dataTransfer) {
|
|
// Files via drag and drop.
|
|
return event.dataTransfer.files
|
|
}
|
|
|
|
return []
|
|
}
|