Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="h-64 border-solid border-black border-4 text-center" id="dropzone">
Drop files here
</div>
<form action="test.php" enctype="multipart/form-data" method="post">
<input type="file" name="files[]" id="files" multiple>
<button type="submit">Send</button>
</form>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
var $dropzone = $('#dropzone');
$dropzone.on('drag dragstart dragend dragover dragenter dragleave drop', function (event) {
event.preventDefault();
event.stopPropagation();
}).on('drop', function(event) {
document.querySelector('#files').files = event.originalEvent.dataTransfer.files;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.