From: Ardis Lu Date: Wed, 15 May 2024 04:28:30 +0000 (-0700) Subject: Add basic drag and drop upload functionality X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=8da2b4bb7d6f3bce5e29d9b4258cdf6e33fd46a3;p=targz Add basic drag and drop upload functionality --- diff --git a/index.html b/index.html index 78a9664..608f9af 100644 --- a/index.html +++ b/index.html @@ -185,6 +185,13 @@ e.submitter.removeAttribute('data-loading'); e.submitter.setAttribute('data-complete', ''); }); + + // Enable drag and drop files + window.addEventListener('dragover', e => e.preventDefault()); + window.addEventListener('drop', e => { + e.preventDefault(); + document.querySelector('input').files = e.dataTransfer.files; + });