https://blog.51cto.com/ITEvan/6459885
Code:var dropHandler = function(e) { e.preventDefault(); // Get the file list var fileList = e.dataTransfer.files; // Detects whether a file is dragged to the page if (fileList.length == 0) { return; } // Check whether the file is a picture if (fileList[0].type.indexOf("image") === -1) { return; } // Instantiate the file reader object var reader = new FileReader(); var img = document.createElement("img"); reader.onload = function(e) { img.src = this.result; oDragWrap.appendChild(img); }; reader.readAsDataURL(fileList[0]); };




Reply With Quote