]> git.ardis.lu - targz/commitdiff
Add basic drag and drop upload functionality
authorArdis Lu <ardisglu@gmail.com>
Wed, 15 May 2024 04:28:30 +0000 (21:28 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 15 May 2024 04:28:30 +0000 (21:28 -0700)
index.html

index 78a966411c6a43a900111e31e56fe0bf49c383ce..608f9af3c78f93e343f071bbdd9d0640dce42c52 100644 (file)
       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;
+    });
   </script>
 </body>
 
This page took 0.035728 seconds and 4 git commands to generate.