Last active
August 29, 2015 14:21
-
-
Save MSakamaki/3342600859e14e975405 to your computer and use it in GitHub Desktop.
テスト用コード@ドラッグ&ドロップのファイル版 Drag And Drop Api for File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ary_u8 = new Uint8Array([0x30,0x82,0x06,....]); // byte code | |
var file = new File([ary_u8], 'file name', { | |
lastModified: new Date(0), | |
type: "application/json" | |
}); | |
var dispatchDrop = function(ary_u8){ | |
var createEvent= function(type) { | |
var event = document.createEvent("CustomEvent"); | |
event.initCustomEvent(type, true, true, null); | |
event.dataTransfer = { | |
files: [ ary_u8 ] | |
}; | |
return event; | |
} | |
var type = 'drop'; | |
var elm = document.querySelector('.upload-drop-zone'); | |
var event = createEvent( type ); | |
elm.dispatchEvent( event ); | |
} | |
dispatchDrop(file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment