Uploading Photos within Facebook Apps
Facebook recently released the Facebook Platform which allows developers to write applications and tools that run inside users’ profiles and within Facebook itself. So far, the Platform has been a huge success. Dozens of useful applications are coming out every day and most users are very excited for the extra functionality.
I am in the process of writing an application that brings together Flickr sets and Facebook photo albums. Unfortunately, the current implementation of the Facebook Platform lacks the ability to easily upload photos to a user’s account.
To remedy this situation, Paul Wells and I decided to writing our own addition to the Facebook PHP5 Client Library. Using it is as simple as uploading the file to your server and changing two lines of code in your existing applications. The best part is that our class does not involve code hacks at all. Our classes simply extend the current ones and add the functionality we want. The advantage to this approach is that the code will still work if Facebook updates the API.
To download the code and see an example of it’s use, visit the project page.




















Hi,
Thanks for this…I’m a bit new to php (came from java bkgrd). The fb photo lib u provided works well with photo files already up on a webserver…is there a way i can get upload file from my local hd to facebook directly?
Thanks in advance.
You can’t upload directly from your computer. You need to use an upload form to upload it to your server, and then upload it to Facebook from there.
Here is a good tutorial on how to do that.
Good luck!
thanks. I will give that a shot.
Rob
Hi,
Another question…FB/PHP related. I was following the http://www.w3schools.com/php/php_file_upload.asp tutorial, and all is well OUTSIDE of Facebook.
So, when i was inside of facebook, i have normal html form code. When submit is pressed, the filename doesn’t seem to get pass to .php file that actually does the uploading… any idea?
Thanks again,
Rob
I’ve never uploaded files using the Facebook Platform, but it shouldn’t be any different. You can try using
to see if your file is available anywhere.
A better place for these type of questions would be the Facebook Developers Group and the discussion board provided there.
Thanks for the great library.
I’m trying to use it with the php4 library and I’m having some trouble with the api_client->users_isAppAdded() function. It appears to fail and I cannot figure out why or what going on. I’m certain the php4 library works fine and your code looks like it extends the class so I’m not sure why would it effect this method.
Thanks,
Bailey
We never tested it with the PHP4 library, so I can’t provide any help in that regard. Sorry.
When I use the example code provided, it doesn’t upload the image to the specified album. If I don’t specify an album, it creates a new one for my application but still doesn’t upload the image.
Any idea what could be wrong?
Hey Guys,
Great work!
If I don’t include the following line :
$albums = $this->facebook->api_client->photos_getAlbums($user, null);
The photo gets uploaded twice. weird stuff…
I can’t download it. When I click the download link at the http://wiki.eyermonkey.com/Facebook_Photo_Uploads page it just brings me to this blog. The link in this blog just brings me back to the other page.
Is there a working sample? Is this going to be easier than setting it up myself?
the link doesnt work!!
would be great, if you could made the zip available again!
thanks
I apologize for the file being missing for a while. I switched servers and forgot to re-upload it. It’s available for download again.
Were you guys going to update this any time soon to work with the new facebook stuff? It doesn’t seem to work @ all even with the code update on the project site.
Would be great to have a working version of this function
Anyone out there know how to upload pics to an application’s album?
thanks for the library - implementation was a breeze!
i can’t seem to find much information about how the API interacts with FB pages(as opposed to your personal profile). does anyone know if there is a way to upload photos to an FB page (either as an admin or a fan)?
Hi,
I’m from Indonesia.i’m sorry if my english is bad.I have s60 phone (n3230).In its gallery,there is upload photo facility.When i choose it,a dialog said,”No image server defined.Define one now?”.Is it can able us to upload photos to our Facebook account?If can,what is the address ‘web server’that we must fill in image server setting?Thanks a lot and i hope there will be an answer to me about this.
Hello,
I am creating an application in Facebook, one of the functionality is to upload an image. When I do so, I do not get anything in $_FILES array.
Please help.