Fix file pasting not working if Firefox

This commit is contained in:
Cohee 2024-06-30 19:13:13 +03:00
parent 4d67d7d748
commit 67d2bb9891
1 changed files with 7 additions and 1 deletions

View File

@ -1526,7 +1526,13 @@ jQuery(function () {
const fileInput = document.getElementById('file_form_input');
if (!(fileInput instanceof HTMLInputElement)) return;
fileInput.files = event.clipboardData.files;
// Workaround for Firefox: Use a DataTransfer object to indirectly set fileInput.files
const dataTransfer = new DataTransfer();
for (let i = 0; i < event.clipboardData.files.length; i++) {
dataTransfer.items.add(event.clipboardData.files[i]);
}
fileInput.files = dataTransfer.files;
await onFileAttach(fileInput.files[0]);
});
});