I have this input to upload an image:
<input type="file" id="file" class="file" />
Then I have a Codebird postTweet() function, var img64 is to convert it to base64 and strip it of its MIME types, but this is not working with "img.toDataURL()". Can anyone tell me what's wrong with this code or what is missing?
var cb = new Codebird;
cb.setConsumerKey("xxx", "xxx");
cb.setToken("xxx", "xxx");
var mediaid = "";
var img64 = img.toDataURL().split(",")[1];
var params = {
"media_data": img64
};
cb.__call(
"media_upload",
params,
function (reply, rate, err) {
mediaid = reply.media_id_string;
console.log(reply);
cb.__call(
"statuses_update", {
media_ids: mediaid,
status: msg
},
function (reply, rate, err) {
console.log(reply);
}
);
}
);