Loading ...
Sorry, an error occurred while loading the content.
 

Re: Downloading images with a PHP script

Expand Messages
  • Vinu Thomas
    You ll also have to send the right headers to the browser from the server. For example for a gif image you d have to send the following header before you
    Message 1 of 3 , May 14, 2007
      You'll also have to send the right headers to the browser from the
      server. For example for a gif image you'd have to send the following
      header before you stream the image content through file_get_contents.

      header("Content-type: image/gif");

      Regards,
      Vinu

      --- In bang-phpug@yahoogroups.com, "thisistrinath" <thisistrinath@...>
      wrote:
      >
      > I am making a search engine( you heard it right)(mainly for India and
      > then US, because it will lack the video and maps search initially).
      > Everything is fine about the searching HTML files and other
      > formats(because of compression method that I use to save them), but
      > the real problem is with the images.
      >
      > First of all, I don't know how to download images on web with a PHP
      > script. Say, if I use
      > file_get_contents(http://www.google.com/intl/en_ALL/images/logo.gif)
      > and display the content in a web page, all I am getting is a code
      > which I don't understand. I think that is the GIF format.
      > But the question I am asking is how to show it back as an image on a
      > web page? (and also help me changing its size as I cannot show it as
      > is in the results)
      >
      > Please answer anything you know on this. Anything will be helpful.
      >
    • CS Shyam Sundar
      Hey., May be, try this: let the image downloading php script be: myimagedownloader.php let it take a parameter called url. Therefore it becomes:
      Message 2 of 3 , May 14, 2007
        Hey.,

        May be, try this:

        let the image downloading php script be: myimagedownloader.php

        let it take a parameter called url. Therefore it becomes:
        myimagedownloader.php?url=http://a.b.com/img.gif

        in your main php file, wherever you want to display the image let it be <
        img src = myimagedownloader.php?url=http://a.b.com/img.gif > < / img >

        Note: For security reasons, check the url parameter to allow only gif, jpg,
        etc., else XSS, Cookie Stealing attacks may be done


        --
        CS Shyam Sundar

        "In our world of game and con: there is always an opponent and there is
        always a victim. The trick: is to know when you're the latter, so you can
        become the former."

        On 5/12/07, thisistrinath <thisistrinath@...> wrote:
        >
        > I am making a search engine( you heard it right)(mainly for India and
        > then US, because it will lack the video and maps search initially).
        > Everything is fine about the searching HTML files and other
        > formats(because of compression method that I use to save them), but
        > the real problem is with the images.
        >
        > First of all, I don't know how to download images on web with a PHP
        > script. Say, if I use
        > file_get_contents(http://www.google.com/intl/en_ALL/images/logo.gif)
        > and display the content in a web page, all I am getting is a code
        > which I don't understand. I think that is the GIF format.
        > But the question I am asking is how to show it back as an image on a
        > web page? (and also help me changing its size as I cannot show it as
        > is in the results)
        >
        > Please answer anything you know on this. Anything will be helpful.
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.