Gracias, Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 function sendFile(file) {2  var uri = "/request";3  var xhr = new XMLHttpRequest();4  var fd = new FormData();5  6  xhr.open("POST", uri, true);7  xhr.onreadystatechange = function() {8  if (xhr.readyState == 4 && xhr.status == 200) {9  // Handle response.10  alert(xhr.responseText); // handle response.11  }12  };13  fd.append('myFile', file);14  // Initiate a multipart/form-data upload15  xhr.send(fd);16 }17 18 window.onload = function() {19  var dropzone = document.getElementById("dropzone");20  dropzone.ondragover = dropzone.ondragenter = function(event) {21  event.stopPropagation();22  event.preventDefault();23  }24 25  dropzone.ondrop = function(event) {26  event.stopPropagation();27  event.preventDefault();28 29  var filesArray = event.dataTransfer.files;30  for (var i=0; i<filesArray.length; i++) {31  sendFile(filesArray[i]);32  }33  }34 }
Enlace
El enlace para compartir es: