Facebook JavaScript SDK – Photo upload from Canvas

This article explains how to upload a photo to Facebook with the Graph API, directly from a Canvas element. No server is needed, as in my recent article about Facebook upload with FormData.

Basically, you just have to get the Canvas data as a Base64 String, turn it into a Blob and use the Blog to upload the picture. The function to turn a Base64 String into a Blob is well known and can be found on Stackoverflow, Github and other platforms. It is basically always the same:

With that function in our pocket, it is quite easy to upload a Canvas image to Facebook:


3 thoughts on “Facebook JavaScript SDK – Photo upload from Canvas

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.