html5 fileapi binary data
Can you get the binary data from a file without the fileReader class? I'm trying to upl开发者_运维知识库oad files and I have it working in firefox & chrome/webkit but safari 5 doesn't have filereader.
There has to be a way to get the binary data as gmail has drag and drop that works in safari 5.
I worked it out, thanks to the demo here: http://webreflection.blogspot.com/2009/03/safari-4-multiple-upload-with-progress.html
I just need to feed the dataTransfer File...
var file = e.dataTransfer.files[0];
var xhr = new XMLHttpRequest();
xhr.open("POST", "upload_process.php", true);
xhr.send(file); //passing in file object seems to work
I have been facing the same problem but i am still not sure about the xhr.send(file). As while using the ASP.NET i got the error "Potentially dangerous data is detected ... ". I thought xhr.send(file) is not implemented by Safari considering FireReader itself is missing.
Its nice to know that xhr.send(file) works in the Safari. I will try investigate it further.
However there is a better alternative for this which works great FormData.
var file = e.dataTransfer.files[0];
var xhr = new XMLHttpRequest();
xhr.open("POST", "upload_process.php", true);
var fd= new FormData(); //its supported in the safari, chrome and firefox 4
fd.append(file.name, file);
xhr.send(fd); //passing in file object seems to work
There is one more issue i am facing right now, its HTML5 DataTransfer detection error in Chrome please let me know in case you have faced and found any solution for this.
精彩评论