Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7988015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:18:50+00:00 2026-06-04T12:18:50+00:00

Can you tell me what I do wrong. I use PHP. Try to upload

  • 0

Can you tell me what I do wrong. I use PHP. Try to upload the photo into users profile.. I get permissions and it works. But uploading doesn’t work, I tryed many ways. So what do I do wrong?

  <?php

   include_once 'facebook.php';

       $facebook = new Facebook(array(
       'appId'  => 'ID',
       'secret' => 'SECRET',
       'cookie' => true,
       'domain' => 'DOMAIN',
       'fileUpload' => 'true'
       ));



      $session = $facebook->getSession();

      if (!$session) {

       $loginUrl = $facebook->getLoginUrl(array(
        'canvas' => 1,
        'fbconnect' => 1,
        'display' => 'page',
        'req_perms' => 'user_likes, publish_stream',
        'next' => 'NEXTURL'
   ));

      echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";

    } else{


     try {

       $uid = $facebook->getUser();
       $me = $facebook->api('/me');
       $token = $session['access_token'];//here I get the token from the $session array
       $album_id = 'ALBUM ID';  /// what should I write here?

       //upload your photo
     $file= 'logo.png';
    $args = array(
       'message' => 'Photo from app',
    );
    $args[basename($file)] = '@' . realpath($file);

   $ch = curl_init();
  $url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;
   curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
   $data = curl_exec($ch);

  //returns the id of the photo you just uploaded
  print_r(json_decode($data,true));



  } catch(FacebookApiException $e){
  echo "Error:" . print_r($e, true);
  }
  }
  ?>

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:18:52+00:00Added an answer on June 4, 2026 at 12:18 pm

    You must add the property fileUpload==true to the Facebook-Object:

    $facebook = new Facebook(array(
        'appId'  => 'ID',
        'secret' => 'SECRET',
        'cookie' => true,
        'domain' => 'DOMAIN',
        'fileUpload' => true
    ));
    

    UPDATE:

    I always use this code to upload photos:

    $photo= $facebook->api(array('method'=>'photos.upload',
                'caption'=>SOME_TEXT,
                'file'=>'@'.$file));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone tell me what is wrong with this code? <?php $user = $fgmembersite->UserFullName();
I have PHP 5.3.4 and when I try to use debug_print_backtrace, I don't get
Anyone can tell me what I'm doing wrong? I am creating a simple system
Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can you tell me what's wrong with my method? I ends up putting the
Can anyone tell me what's wrong with this code? It's giving me an error
Can someone tell me what is wrong with my code? $c = '<div class=desc>';
Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{
Can anyone tell me where I am going wrong... I am using the following
Can someone please tell me whats wrong with this code. I'm not getting complete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.