Hack Forums
CURL Image, based on url (gif/png/jpg) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: CURL Image, based on url (gif/png/jpg) (/showthread.php?tid=4500432)



CURL Image, based on url (gif/png/jpg) - 'An0ny - Oct 21, 2014

Can someone here give me a script that curl's image from another domain.

If the get request is PNG, then it outputs it as PNG header.. If it's JPG, it outputs it as JPG Header...

It only has to work with images, with extensions png/gif/jpg

PHP Code

<?php 
$ch 
= curl_init ("http://www.google.com/images/logos/ps_logo2.png");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$image = curl_exec($ch);
curl_close ($ch);
header("Content-Type: image/png");
echo 
$image;
?>
^ Example this would echo image/png automaticly as the url is png header.. it wouldnt accept php files, html or output anything but images ? lol