javascript - Drag and Drop Html 5 file upload - Prevent loading -


I still have this code. I can see the dragentve and dragleave events, but when I leave the file, the browser opens (Chrome or Firefox) file (even a picture) Anyone who is called preventDefault () sees any mistake? What should I change?

  & lt; Script type = "text / javascript" & gt; $ (Function () {var $ box = $ ("# ulbox"); $ box.bind ("dragenter", dragEnter); $ box.bind ("dragleve", drag lev); $ box.top ("drop ", Drop); function dragor (evt) {evt.stopPropagation (); evt.preventDefault (); console.log (" dragent ... "); $ (evt.target) .addClass ('over'); back Return;} function drag lev (evt) {evt.stopPropagation (); evt.preventDefault (); console.log ("drag drag ..."); $ (evt.target) .removeClass ('over'); return Returned;} function drop (evt) {evt.stopPropagation (); evt.preventDefault (); $ (evt.target) .removeClass ('over'); var file = evt.originalEvent.dataTransfer.files; if (files. Length> 1) {Warning ("left"); if (vs Ndo.formadata! == undefined) {var data = new form data (;; i & lt; files; height; i ++) {data.append ("file" + i, file [i {}};}}. $ {AJAX} ({Type: "Post", URL: "/ API / Upload", Content Type: Wrong, Process Data: Incorrect, Data: Data, Success: Function} {}}) Warning ("Browser is useless!");}} Return false;}}); & Lt; / Script & gt; } & Lt; Div id = "ulbox" style = "border: 5px dashed black; width: 300px; height: 100px;" & Gt; & Lt; / Div & gt;    

remove $ box.bind ("dragleave", drag-leave);

Add it: $ box.bind ("dragover", skip drag);

This attraction works

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -