Greetings ,
I can drag drop an image already on page ,
But How to Drag Drop “image file” into html page ,
I don’t want to Upload , just DnD .
<!DOCTYPE HTML>
<html>
<head>
<style>
#div1 {
width: 100px;
height: 200px;
padding: 10px;
border: 1px solid #aaaaaa;
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body ondrop="drop(event)" ondragover="allowDrop(event)">
<p>Drag image into the rectangle:</p>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<br>
<img id="drag1" src="https://m.media-amazon.com/images/W/MEDIAX_849526-T1/images/I/71nMsinO2sL._AC_SX679_.jpg" draggable="true" ondragstart="drag(event)" width="100" height="200">
</body>
</html>
Thanks for your Help…