in reply to Content-type: html and images ?

You need 2 scripts.
The first one generates HTML with a link to the image. The link might look something like <img src="script.pl?action=showImage&id=234">

The script that makes the gif can print it straight from the database to STDOUT

Replies are listed 'Best First'.
Re: Re: Content-type: html and images ?
by Anonymous Monk on Feb 10, 2003 at 14:31 UTC
    Thanks, but I'm still having problems :( a little more explanation would be great :)

    I'm confused about the showImage action.
    I have this in my html generating script:
    print STDOUT "<IMG SRC=\"show_pic.cgi\" action=showImage>";
    where show_pic is my gif printing script. I dont understand the showImage action.
    Say $gif_file is the pathname to the gif I want opening.
    Is the &id in Jaap's example giving the right image path to the gif displaying script ?
    (ie. 234 is the gif that would be opened)
    thanks

      Why do you always explicitly print to STDOUT? That's unnecessary unless you've used select to change the default output filehandle.

      You need to re-read the sugggest that you were given. "action" is a parameter to your CGI program. Therefore you should have this:

      print STDOUT "<IMG SRC=\"show_pic.cgi?action=showImage\">";
      or (more idiomatically)
      print qq(<IMG SRC="show_pic.cgi?action=showImage">);
      Then within show_pic.cgi you can check for the value of the "action" parameter and take appropriate action (i.e. returning either the HTML page or the image).

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        okay, Im still being stupid :(
        Have got rid of the print STDOUT's at least ! (I thought this was
        needed, a web tutorial on CGI used print STDOUT)

        I still don't get how my image path is fed to the show_pic.cgi
        Must I access the database in show_pic.cgi rather than in the script that generates the html ?

        sorry to be so thick ! Its a monday....
        thanks for all your help