Monday, 9 September 2013

PHP Displaying broken image

PHP Displaying broken image

I'm trying to get an image from an external URL and use information from a
local MySQL database in that external URL.
I have the following code:
<?php
define('USERNAME_REQUIRED', TRUE);
define('ACCOUNT_REQUIRED', TRUE);
include('../global.php');
define("THIS_SCRIPT", 'fanapi');
if(isset($_GET['u']))
{
$username = $core->EscapeString($_GET['u']);
}
else
{
$username = $core->EscapeString($_SESSION['username']);
}
$getFigure = mysql_query("SELECT look FROM users WHERE
username='".$username."' LIMIT 1");
$figure = mysql_result($getFigure, 0);
$action = $_GET['action'];
$direction = $_GET['direction'];
$head_direction = $_GET['head_direction'];
$gesture = $_GET['gesture'];
$size = $_GET['size'];
$imgFile = "$figure$action$direction$head_direction$gesture$size";
$imagesPath = $imgFile;
$otherSiteUrl =
"http://externalsite.com/img/image.php?figure=$figure&action=$action&direction=$direction&head_direction=$head_direction&gesture=$gesture&size=$size";
file_get_contents($imagesPath, file_get_contents($otherSiteUrl));
header("Content-Type: image/png");
//$url = ("http://externalsite.com/cache/cache.php?figure=".$figure."");
//header('Content-Type: image/png');
//echo $url
//exit(file_get_contents($url));
?>
The scripts runs without showing a 500 error however the image appears
broken.
When I echo $url I get the right URL, but for some reason I get a broken
image when I try to make an image from it.
What am I missing?

No comments:

Post a Comment