最简单的html5文件拖放示例

示例代码:




  
  Document
  


  
var droptarget = document.getElementById('droptarget');

function handleEvent(event) {
    event.preventDefault();
    if (event.type === 'drop') {
      event.preventDefault();
      files = event.dataTransfer.files;
      console.log(files);
    }
}
droptarget.addEventListener('dragover', handleEvent);
droptarget.addEventListener('drop', handleEvent);

你可能感兴趣的:(最简单的html5文件拖放示例)