I'm trying to cache an users look from an external website and cache it locally in the same folder. I've come up with this so far:
<?php
$figure = $_GET['figure'];
$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;
if(!file_exists(($imagesPath))) {
$otherSiteUrl = "http://sourcewebsite.com/image/look?figure=$figure&action=$action&direction=$direction&head_direction=$head_direction&gesture=$gesture&size=$size";
file_put_contents($imagesPath, file_get_contents($otherSiteUrl));
}
header("Content-Type: image/png");
readfile($imagesPath);
?>
This worked for a while until today. I am not sure why. It just returns a broken image icon.
file_exists($imagesPath)
return true? Or is it requesting the image? If it's requesting the image, are you getting any content returned in thefile_get_contents
?