0

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);
            }
        );
    }
);
knights
  • 1
  • 2
  • thinking of https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL ? – dandavis Mar 28 '17 at 18:09
  • @dandavis So would I do this: `` and then declare `var canvas = document.getElementById('canvas'); var img64 = canvas.toDataURL().split(",")[1];` – knights Mar 28 '17 at 18:28

0 Answers0