jquery-filedrop
jquery-filedrop copied to clipboard
<XMLHttpRequest> has no method 'sendAsBinary'
Getting:
Uncaught TypeError: Object #<XMLHttpRequest> has no method 'sendAsBinary'
In Chrome 29.0.1547.76 using latest version of filedrop.js.
Seems to be breaking here:
xhr.sendAsBinary(builder);
The function sendAsBinary() seems to have been removed from Chrome.
I think you can do something like:
if(!XMLHttpRequest.prototype.sendAsBinary){
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
this.send(ui8a.buffer);
}
}
Any update on this?
Even implementing:
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
this.send(ui8a.buffer);
}
Does not fix the error. Really need a solution to this. Thanks much.
Just a quick drop for those who will have this issue. The solution provided http://royaltutorials.com/object-has-no-method-sendasbinary/ did the trick for me. Just replacing the "XMLHttpRequest.prototype" by "xhr". Cheers.
@havenS This code is already implemented https://github.com/weixiyen/jquery-filedrop/blob/master/jquery.filedrop.js#L537 but does not seem to work. I am still getting:
Uncaught TypeError: Object #<XMLHttpRequest> has no method 'sendAsBinary'
With Chrome (32.0.1700.107). Any ideas?
The error triggered by Chrome Version 32.0.1700.107 m was on line 402. This tweak is not implemented on l.402, that did the trick for me on that line http://jsfiddle.net/MKrLa/2/ . Hope it's not luck I had.
@havenS Awesome that worked. Thanks so much! Maybe we should create a PR and merge this change in?
Nice ! I very glad it worked for you. I'll create the PR. Cheers.
How to change the file name? Why can not I pass a file name and change it from js in php? Implement please!
Not sure what you're trying to achieve. You need to change the filename in your php handler by passing it through the upload process ? If so, pass it to the params.
I want to assign a new file name from the temporary folder and pass it to php? Sorry, i know bad English.
In your filedrop instantiation you can set the 'data' array in which you can define any parameter that you catch later in you process: $('#yourDropZone').filedrop({ data: { params1:
Thank you very much! You really helped. I spent 2 days on it. I'm really grateful to you!
Here's what happened: var fname = document.getElementById("names").value;
dropbox.filedrop({
// The name of the $_FILES entry:
paramname:'pic',
data: {"nick":fname},
params:'nick',
The file - jquery.filedrop.js
(function($){ jQuery.event.props.push("dataTransfer"); var opts = {}, default_opts = { url: '', refresh: 1000, paramname: 'userfile', params: 'nick',
Ok if I understand well, your problem is solved ? If so, glad you can move forward on your project. For reference, here is the "how to" which led me to this library on the first time. If it can be of any help for others: http://tutorialzine.com/2011/09/html5-file-upload-jquery-php/