Upload base64 encoded images using Facebook sdk?

It's possible to upload base64 encoded images directly without saving it using Facebook PHP SDK 3.1.1?

$facebook->api('/me/photos', 'POST', array(
    'source' => '@/mycoolpic.png', // No need to use FS, base64 encoded image
    'message' => "I'm cool",


No, not that I have been aware of, or found out searching. Make sure you use realpath() around the image name, to give the absolute path to the image.

You can do as follow in PHP :

function base64_to_jpeg( $base64_string, $output_file ) {
  $ifp = fopen( $output_file, "wb" ); 
  fwrite( $ifp, base64_decode( $base64_string) ); 
  fclose( $ifp ); 
  return( $output_file ); 
$image = base64_to_jpeg( $your_base64_string, 'tmp.jpg' );
$args = array('message' => 'Some message');
$args['image'] = '@' . realpath( $image );
$data = $facebook->api('/your_user_id/photos', 'post', $args);

Need Your Help

Regex Split String at particular word pattern different different value

asp.net regex vb.net oracle

I am doing dynamic reporting system. For Front End i using Asp.net and oracle as Back End. Project requirement is that, user can write query in a TextBox and when click on button from the Query after

Cakephp form never validates when it should

php validation cakephp

Ok, so I have validation somewhat working. It doesn't validate when it SHOULD, which seems to be the opposite of every problem I can find on google. I've tried copying the exact code from the CakePHP