Skip to content

Instantly share code, notes, and snippets.

@carloscarucce
Forked from nicoptere/imageProxy.php
Last active March 10, 2024 09:55
Show Gist options
  • Save carloscarucce/89329fa61997b3775487b0c155cda41f to your computer and use it in GitHub Desktop.
Save carloscarucce/89329fa61997b3775487b0c155cda41f 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 ($imgInfo === false) {
die('Could not retrieve information');
}
if (stripos($imgInfo['mime'], 'image/') === false) {
die('Invalid image file');
}
header("Content-type: ".$imgInfo['mime']);
readfile( $url );
@Looper1984
Copy link

@carloscarucce right, that's much safer and exactly what I'm doing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment