Skip to content

Instantly share code, notes, and snippets.

@cccaldas
Created September 11, 2012 02:26
Show Gist options
  • Save cccaldas/3695486 to your computer and use it in GitHub Desktop.
Save cccaldas/3695486 to your computer and use it in GitHub Desktop.
proxy.php
<?php
$filename = $_GET["url"];
$fsize = getSizeFile($filename);
header("Content-Type: image/jpeg");
header("Content-Length: ".$fsize);
readfile($filename);
function getSizeFile($url) {
if (substr($url, 0, 4) == "http") {
$x = array_change_key_case(get_headers($url, 1), CASE_LOWER);
if (strcasecmp($x[0], "HTTP/1.1 200 OK") != 0) {
$x = $x["content-length"][1];
}
else {
$x = $x["content-length"];
}
}
else {
$x = @filesize($url);
}
return $x;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment