Make a div for dropping.
$("#id").on("drop dragover", function(e) {
var fm = document.getElementById('form');
var fd = new FormData(fm);
e.preventDefault();
if (e.type === "drop") {
var files = e.originalEvent.dataTransfer.files;
console.log(files);
if (files.length > 0) {
fd.append("file", files[0]);
// do something
}
}
return false;
});
html part:<form action="upload.php" enctype="multipart/form-data" id="form" method="post">
<input name="mode" type="hidden" value="upload" />
<input id="formFile" name="file" type="file" />
</form>
No comments :
Post a Comment