Skip to content

Instantly share code, notes, and snippets.

@SathyaBhat
Created December 20, 2010 17:05
Show Gist options
  • Save SathyaBhat/748648 to your computer and use it in GitHub Desktop.
Save SathyaBhat/748648 to your computer and use it in GitHub Desktop.
Stupid php code to fetch images from remote server & serve it to you.
# Stupid php code to fetch images from remote server & serve it to you. Takes single image URL only.
# Replaces prior images. No caching. Horribly n00bish. Don't flame me, written with no php knowledge
index.php:
---
<HTML>
<HEAD>
<TITLE>Image Grabber </TITLE>
</HEAD>
<BODY>
<FORM method="post" ACTION="fetch_images.php">
URL: <input type=text name="ImgUrl" size="80">
<INPUT TYPE=SUBMIT />
</BODY>
</HTML>
fetch_images.php
-----
<?php
$imgurl = $_REQUEST['ImgUrl'];
echo 'Requested image: '; echo $imgurl;
echo '<br />';
echo 'Fetch another <a href="http://your-domain/">image</a>?<br/>';
$img = 'img.png';
file_put_contents($img, file_get_contents($imgurl));
?>
<img src ="img.png" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment