Amit K 4:22pm, 26 July 2009
After wading through loads of docs and web i still have not found a single WORKING PHP script (just 1 page, not a framework) which simply uploads a image to flickr

I mean all that is required is

//set all the variables for authentication


//call upload method with image parameters

i see lots of discussions but not a simple working script.

All the above might be true because flickr does authentication with more than just username/password way. Any idea why flickr does not allow a simple usrname/pwd technique to upload the file ?

dopiaza 10 years ago
Any idea why flickr does not allow a simple usrname/pwd technique to upload the file ?

Because it's dreadfully insecure?
Amit K 10 years ago
well dont we authenticate against webmails like gmail and yahoo via HTTPS everyday ?
Sam Judson 10 years ago
You don't use https for gmail? then you are insecure.

If you are using PHP then there is no need to do the hard work yourself, and it is FAR easier to use phpFlickr. So the below is a single page that will upload an image to Flickr (but using phpFlickr).

Don't forget to point your API key callback url to the auth.php page, and set the api key and shared secret in the below file and auth.php/.

To do it without phpFlickr requires a lot of work.



$f = new phpFlickr($apikey, $secret);
$f->sync_upload("test.jpg", $title = "the title", $description = "the description", $tags = "tag1,tag2");

abhijitkt 10 years ago
Where can i find the phpFlickr.api and auth.php files...

@ Sam Judson:

Can you give us some more insights into uploading photos to flickr..

The above code isn't very clear..
Sam Judson Posted 10 years ago. Edited by Sam Judson (admin) 10 years ago
Well a quick google for phpFlickr would probably have given you the answer:
hilsman 10 years ago

I used the code u mentioned above .. but it doesn't work .It redirects me to callback URL. Were u success in uploading the pics like this?
StormIT Posted 9 years ago. Edited by StormIT (member) 9 years ago
I am using phpFlickr and have used their files to upload a photo, works great.

How do I go about creating a form to browse for a photo and upload it? Where do the form elements need to go?
anita_mca4 9 years ago
i am trying to upload photos into flickr using phpFlickr
i have api_key,secret,api_sig,token every thing
passing all these parameter but i am getting this error

can any one help me
anita_mca4 9 years ago
i am uploading photos to flickr using my simple code
auth($permissions, false);
} else {
//echo "fb is->".$_GET['frob'];


$filename = basename($_FILES['photo']['name']);
$upload_photo_id=$f->sync_upload($path,'testing fun','','','','','');
echo "photo uploaded successfully";
echo "upload fails".$_FILES['photo']['error'];
// $photo=$f->photos_getInfo($upload_photo_id);
// print_r($photo) ;
// $url=$f->buildPhotoURL($photo);
// echo "".$url."" ;
$username='your username';

// phpFlickr needs a cache folder
// in this case we have a writable folder on the root of our site, with permissions set to 777
//$f->enableCache("fs", "cache");
//returns an array
$result = $f->people_findByUsername($username);

// grab our unique user id from the $result array
$nsid = $result["id"];

// Get the user's public photos and show 21 per page
//$page at the end specifies which page to start on, that's the page number ($page) that we got at the start
$photos = $f->people_getPublicPhotos($nsid, NULL, NULL, 21, $page);

// Some bits for paging
$pages = $photos[photos][pages]; // returns total number of pages
$total = $photos[photos][total]; // returns how many photos there are in total


foreach ($photos['photos']['photo'] as $photo) {

echo "";
// this next line uses buildPhotoURL to construct the location of our image
echo "buildPhotoURL($photo, "Square") . "\" width=\"75\" height=\"75\" />";
echo "

} // end loop


1) {
echo "« Prev";
// if not last page
if($page != $pages) {
echo "Next »";}

// a quick bit of info about where we are in the gallery
echo"Page $page of $pages";
echo"$total photos in the gallery";?>

Upload a photo:
ravikiranj.pesit 8 years ago
If anyone is still having trouble finding a suitable php photo uploader script for Flickr, I wrote a detailed post on it. Please refer to it @
iPoliStonKosmo 8 years ago
I tried using the code suggested by Ravikinari but when i upload my photo using the form in the code i get this message:

"The Flickr API returned the following error: #100 - Invalid API Key (Key has invalid format)"

I've generated the token and edited the Authentication Flow but i can go nowhere from there on...

Could anybody please help?
Sam Judson 8 years ago
If you are using phpFlickr as in the article then it must mean your API key is not being specified correctly. Make sure you have not included any spaces in the api key string.
iPoliStonKosmo 8 years ago
hey Sam,

Thank you so much for the quick reply.

Yes I am using the phpFlickr exactt as specified in the article.

I also thought at first that there was a problem with whitespaces but i've checked and rechecked, I've coped and recopied the Api key and still i get the same message....
I don't understand what could be the matter since I am following all the steps in the article and it seems such a straightforward script ....

any further suggestions would be greately appreciated..

Thanks again
ravikiranj.pesit 8 years ago
I know it sounds redundant, but check the API Key + Secret + Token... just regenerate the token, and try again, if this also doesn't work, try generating a new API Key and secret. I have seen other forums ( where they posted this error but it seems that it went away without any changes. I don't know if its a temporal glitch from Flickr.
iPoliStonKosmo 8 years ago
Hello again,
thanks for the replies.

I've registered another app and still no change.

I am able to generate a Token using the same key for the getToken.php script, so I am guessing it is valid and not expired.

I've copied correctly the key and token without any whitespaces....

could the problem lie with my server (I am in Greece and using a Greek server)?
iPoliStonKosmo 8 years ago
Thank you all for your help!

The problem was with my webserver settings!!

Problem solved.

Great working script!!!
ravikiranj.pesit 8 years ago
I'm glad it worked out for you, thanks a lot for using my script ;) !
Go Yogesh Posted 6 years ago. Edited by Go Yogesh (member) 6 years ago
Sam Judson:
$f = new phpFlickr($apikey, $secret);

Once, authenticated, you will get the token. set the token while uploading the photo

$f = new phpFlickr($apikey, $secret);
$f->sync_upload("test.jpg", $title = "the title", $description = "the description", $tags = "tag1,tag2");

It worked for me.
Hello ravikiranj, I have enjoyed your post on how to create a public photo uploader using flickr and I 'm super excited to tackle this project but I hit a roadblock.

I have created an e-commerce site for a client based on the 3DCart platform, but they do NOT allow PHP scripts to be loaded. Is there a Javascript/Jquery alternative for the photo uploader. Also, the current gallery I have installed on his site uses a call for specific photo-sets. So this would be a helpful function as well.

Thanks for your time and effort.

Groups Beta