how to echo an Image using "Get" Method & PHP

Discussion in 'PHP' started by btechzone, Oct 26, 2011.

  1. #1
    btechzone, Oct 26, 2011 IP
  2. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #2
    To simply load an image using the $_GET global is quite easy. Something like this should get you started.
    
    if(isset($_GET['image'])) {
    echo '<img src="'.strip_tags($_GET['image']).'"/>';
    }
    
    PHP:
    You would call the script like this: http://yourdomain.com/image.php?image=http://link-to-image-here

    Hope this helps to get you started
     
    HuggyEssex, Oct 27, 2011 IP
  3. btechzone

    btechzone Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Friend, thank for the code. It worked fine for the images which are in parent directory. But if want use the outside images, i was unable to see the images. the code not working.. please can u provide me for the images which are not on my domain..
     
    btechzone, Oct 28, 2011 IP
  4. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #4
    The code works fine but as you are using the $_GET method you are limited to the amount of characters you can use. An alternative would be to post the image url in a form field. I just tested this locally and it worked fine:
    
    http://yourdomain.com/image.php?image=http://binevils.webs.com/youtube-logo(2).jpg
    
    Code (markup):
     
    HuggyEssex, Oct 28, 2011 IP