title: Upload photo via graph API - multipart/form-data
body: <p>I am trying to create page post links in my page using Graph API. I was able to create the post, but I am having some problems sending the picture to use on it.</p>
  
  <p>I was trying to use pictures that are in my computer, but i found out (here in stackoverflow) that I need to use URLs that are already in the internet or upload the photos from my computes to Facebook first, so I can use then later.</p>
  
  <p>I checked to see how can I upload the photos from my computer via Graph API, and then use this URL for the picture in my post, but i saw that I need to do it using multipart/form-data.</p>
  
  <p>But I didn't understand how to do it (upload photos and get their URL) using  multipart/form-data. Does anyone have an ideia how to do it?</p>
  
  <p>Here's is the PHP code that I am using now:</p>
  
  <pre><code>&lt;?php
  
  
  session_start();
  
  require_once( 'Facebook/FacebookHttpable.php' );
  require_once( 'Facebook/FacebookCurl.php' );
  require_once( 'Facebook/FacebookCurlHttpClient.php' );
  require_once( 'Facebook/FacebookSession.php' );
  require_once( 'Facebook/FacebookRedirectLoginHelper.php' );
  require_once( 'Facebook/FacebookRequest.php' );
  require_once( 'Facebook/FacebookResponse.php' );
  require_once( 'Facebook/FacebookSDKException.php' );
  require_once( 'Facebook/FacebookRequestException.php' );
  require_once( 'Facebook/FacebookClientException.php' );
  require_once( 'Facebook/FacebookOtherException.php' );
  require_once( 'Facebook/FacebookAuthorizationException.php' );
  require_once( 'Facebook/FacebookPermissionException.php' );
  require_once( 'Facebook/FacebookServerException.php' );
  require_once( 'Facebook/GraphObject.php' );
  require_once( 'Facebook/GraphSessionInfo.php' );
  require_once( 'Facebook/GraphUser.php' );
  
  
  
  use Facebook\FacebookHttpable;
  use Facebook\FacebookCurl;
  use Facebook\FacebookCurlHttpClient;
  use Facebook\FacebookSession;
  use Facebook\FacebookRedirectLoginHelper;
  use Facebook\FacebookRequest;
  use Facebook\FacebookResponse;
  use Facebook\FacebookSDKException;
  use Facebook\FacebookRequestException;
  use Facebook\FacebookClientException;
  use Facebook\FacebookOtherException;
  use Facebook\FacebookAuthorizationException;
  use Facebook\FacebookPermissionException;
  use Facebook\FacebookServerException;
  use Facebook\GraphObject;
  use Facebook\GraphSessionInfo;
  use Facebook\GraphUser;
  
  FacebookSession::setDefaultApplication('app','password');
  
  $session = new FacebookSession('token');
  
  
  $message = 'Test';
  $link = "http://www.example.com.br";
  $description = 'Description';
  $name = 'Name';
  $caption = 'Caption';
  // $picture = 'file:///C:/Users/VIrgilio/Desktop/Petlove/Facebook%20Ads/Campanhas/Assento/Link/Assento-Novo.png'; //this is where the picture is in my PC
  
      $request = new FacebookRequest(
        $session,
        'POST',
        '/page_id/feed',
        array (
          'message' =&gt; $message,
          'link' =&gt; $link,
          'description' =&gt; $description,
          'published' =&gt; 'false',
          'name' =&gt; $name,
          'caption' =&gt; $caption,
  //      'picture' =&gt; $picture,  //    the URL from my PC gives me an error, here is where I need to put the URL from the uploaded photo
          )
      );
      $response = $request-&gt;execute();
      $graphObject = $response-&gt;getGraphObject();
  
  ?&gt;
  </code></pre>
  
  <p>Thanks</p>