Created
February 9, 2018 21:05
-
-
Save luisdalmolin/87bbfb9a32e8ddf8d11111832c3f5003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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
Very Nice