javascript - Read the contents of a "file" object? -


so have "file" object (retrieved handling file drag , drop desktop). can send files server ajax, , throw them javascript handle them. possible read contents of without doing this?

here, play around fiddle. drag file box , use variable file.

i've tried of methods of object...no luck. can contents of file dragged browser?

ps: send files server this:

var ajaxrequest = new xmlhttprequest(); ajaxrequest.open("returnrawpostdata.php"); ajaxrequest.send(file); 

i might have missed in code above, that's because 1 doesn't use plain js ajax calls anymore.

using links martin mally (thanks lot!), came this:

var file = e.datatransfer.files[0],read = new filereader();  read.readasbinarystring(file);  read.onloadend = function(){     console.log(read.result); } 

where read.result holds contents of file.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -