title: PHP SCRIPT issue with passing the uploaded image to facebook->api function
body: <p>I have this code and its working awsomely fine if i provide a direct link of an image. </p>
  
  <hr>
  
  <p>Just and just only one problem i am not able to pass my uploaded image to facebook->api (whether its valid or not) and the following always echo </p>
  
  <hr>
  
  <p>echo 'Only jpg, png and gif image types are supported!';</p>
  
  <hr>
  
  <p>i even remove the check on image type and try to get the image from
    $img = realpath($_FILES["pic"]["tmp_name"]);
  but $img gets nothing in it and uploads a by default empty image on facebook as my page 
  Kindly check my following code and let me know what is wrong with my code and what should i do instead to upload images</p>
  
  <p>Online link of the following CODE: <a href="http://radiations3.com/facebook/1.php" rel="nofollow">http://radiations3.com/facebook/1.php</a></p>
  
  <pre><code> &lt;?
  
  
  require 'src/facebook.php';
  
  $app_id = "364900470214655";
  $app_secret = "xxxxxxxx";
  
  $facebook = new Facebook(array(
   'appId' =&gt; $app_id,
   'secret' =&gt; $app_secret,
   'cookie' =&gt; true,
   'fileUpload' =&gt; true,
  ));
  
  $user = $facebook-&gt;getUser();
  //echo $user;
  
  if(($facebook-&gt;getUser())==0)
  {
   header("Location:{$facebook-&gt;getLoginUrl(array('req_perms' =&gt; 'user_status,publish_stream,user_photos,offline_access,manage_pages'))}");
   exit;
  }
  else {
  $accounts_list = $facebook-&gt;api('/me/accounts');
  echo "i am connected";
  }
    $valid_files = array('image/jpeg', 'image/png', 'image/gif');
  
  
  //to get the page access token to post as a page
  foreach($accounts_list['data'] as $account){
        if($account['id'] == 194458563914948){      // my page id =123456789
          $access_token = $account['access_token'];
          echo "&lt;p&gt;Page Access Token: $access_token&lt;/p&gt;";
          }
      }
  
  //posting to the page wall
  
  if (isset($_FILES) &amp;&amp; !empty($_FILES))
  {  
  if( !in_array($_FILES['pic']['type'], $valid_files ) )
  {
    echo 'Only jpg, png and gif image types are supported!';
   }
   else{
    #Upload photo here
    $img = realpath($_FILES["pic"]["tmp_name"]);
  $attachment = array('message' =&gt; 'this is my message',
                  'access_token'  =&gt; $access_token,
                  'name' =&gt; 'This is my demo Facebook application!',
                  'caption' =&gt; "Caption of the Post",
                  'link' =&gt; 'example.org',
                  'description' =&gt; 'this is a description',
                  'picture' =&gt; '@' . $img,
                  'actions' =&gt; array(array('name' =&gt; 'Get Search',
                                    'link' =&gt; 'http://www.google.com'))
                  );
  $status = $facebook-&gt;api('/194458563914948/feed', 'POST', $attachment);   // my page id =123456789
  var_dump($status);
  }
  }
  ?&gt;
  &lt;body&gt;
   &lt;!-- Form for uploading the photo --&gt;
   &lt;div class="main"&gt;
    &lt;p&gt;Select a photo to upload on Facebook Fan Page&lt;/p&gt;
    &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" enctype="multipart/form-data"&gt;
    &lt;p&gt;Select the image: &lt;input type="file" name="pic" /&gt;&lt;/p&gt;
    &lt;p&gt;&lt;input class="post_but" type="submit" value="Upload to my album" /&gt;&lt;/p&gt;
    &lt;/form&gt;
   &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>