You'll need the tmoauth library from twitter. I can't explain how to implement within your code, but this is cut and pasted from my working code, but I had to anonymize some stuff.
//THIS IS THE CREDS FOR TWITTER - I HAVE THEM IN AN ARRAY
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $network_array['consumer_key'],
'consumer_secret' => $network_array['consumer_secret'],
'user_token' => $network_array['user_token'],
'user_secret' => $network_array['user_secret']
));
}
//PARAMS UNIQUE FOR THIS TWEET
$params = array(
'media[]' => '@' . $process_image['image_path'], //PATH TO IMAGE
'status' => $tweet_response, //THIS IS THE TEXT WE USE FOR THE TWEET
'in_reply_to_status_id' => $mentions[$c]["id"] //IF REPLYING, IT'S HERE
);
//THIS IS HOW YOU TELL TWITTER IT'S A PHOTO
$code = $tmhOAuth->user_request(array(
'method' => 'POST',
'url' => $tmhOAuth->url("1.1/statuses/update_with_media"),
'params' => $params,
'multipart' => true
));