1<style>2 div{3 width:300px;4 height:300px;5border:1px Dashed # the;6 Position:absolute;7Top -%;8Left -%;9margin:-150px0 0-150px;Tentext-Align:center; Onefont:20px/300px'Microsoft Ya-Black'; A Display:none; - } -</style> the<script> -Window.onload =function () { - varOBox = document.getElementById ('Box'); - varOM = document.getElementById ('M1'); + varTimer =NULL; -Document.ondragover =function () { + cleartimeout (timer); ATimer =setTimeout (function () { atOBox.style.display ='None'; -}, $); -OBox.style.display ='Block'; - }; - //when you enter a subset, it triggers ondragover frequent triggering without giving OnDrop a chance. -Obox.ondragenter =function () { inobox.innerhtml ='Please release the mouse'; - }; toObox.ondragover =function () { + return false; - }; theObox.ondragleave =function () { *obox.innerhtml ='Please drag the file to this area'; $ };Panax NotoginsengObox.ondrop =function (EV) { - varOfile = ev.datatransfer.files[0]; the varReader =NewFileReader (); + //Read Success AReader.onload =function () { the Console.log (reader); + }; -Reader.onloadstart =function () { $Alert'Read Start'); $ }; -Reader.onloadend =function () { -Alert'Read End'); the }; -Reader.onabort =function () {WuyiAlert'Interrupts'); the }; -Reader.onerror =function () { WuAlert'Read failed'); - }; AboutReader.onprogress =function (EV) { $ varScale = ev.loaded/ev.total; - if(scale>=0.5){ -Alert1); - Reader.abort (); A } +Om.value = scale* -; the }; -Reader.readasdataurl (Ofile,'Base64'); $ return false; the }; the }; the</script> the -<body> in<meter id="M1"Value="0"min="0"max=" -"></meter> the<div id="Box"> Drag the file to this area </div> the</body>
File drag and drop upload