# Upload image to Facebook

**URL:** <https://forum.kirupa.com/t/upload-image-to-facebook/327835>\
**Category:** flash\
**Created:** [March 30, 2012, 7:34pm UTC](https://forum.kirupa.com/t/upload-image-to-facebook/327835 "2012-03-30T19:34:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tstefan](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tstefan](https://forum.kirupa.com/u/tstefan)\
**Post date:** [March 30, 2012, 7:34pm UTC](https://forum.kirupa.com/t/upload-image-to-facebook/327835/1 "2012-03-30T19:34:14Z")

</div>

Hello,

Iam trying tu upload image to facebook but it just dont work, doe’s someone knows relaiable and working example, because everythig I use it don’t work.

```auto
//Facebook API
		private function handleInit(response:Object, fail:Object):void 
		{				
			status_tf.text = 'handleInit response= ' + response + ":fail= " + fail;
			
			if(response != null)
			{
				status_tf.text = 'Photo will be uploaded to your Facebook.';
				upload();
			}
			//handleLogin(response, fail);
		}
		
		
		private function handleLogin(response:Object, fail:Object):void 
		{
			if (response) 
			{
				post_mc.enabled = false;
				status_tf.text = 'Photo will be uploaded to your Facebook.';
				upload();
			}
			else 
			{					
				status_tf.text = 'Click "login" to start';
			}
		}
		
		
		protected function login(event:MouseEvent):void 
		{
			trace("login");
			target_mc.dispatchEvent(new Event(CONNECTED));
			Facebook.login(handleLogin, {perms:"user_photos, publish_stream"});
		}

		
		protected function upload():void 
		{
			
			
			var img:ByteArray = parent_class.model.getImageData();
			
			status_tf.text = 'Photo uploading! image_btm= ' + image_btm;
			var values:Object = {message:'Message', 
								fileName:"FILE_NAME", 
								//picture:imagePath_str
								image:image_btm.bitmapData
								/*image:img*/};
			
			Facebook.api('/me/feed', handleUploadComplete, values, "POST");
		}
		
		protected function handleUploadComplete(response:Object, fail:Object):void 
		{
			status_tf.text += (response!=null) ? 'Successfully uploaded!' : 'Error uploading!';
		}
		

```
