Skip to content

Instantly share code, notes, and snippets.

@laocoi
Forked from carloscarucce/imageProxy.php
Created June 2, 2018 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laocoi/97c4ea81f6a246fad80ece44f105b703 to your computer and use it in GitHub Desktop.
Save laocoi/97c4ea81f6a246fad80ece44f105b703 to your computer and use it in GitHub Desktop.
basic PHP image proxy (that works ... )
<?php
$url = isset($_GET['url']) ? $_GET['url'] : null;
if (!$url) {
die('Please, inform URL');
}
$imgInfo = getimagesize( $url );
if (stripos($imgInfo['mime'], 'image/') === false) {
die('Invalid image file');
}
header("Content-type: ".$imgInfo['mime']);
readfile( $url );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment