in reply to Re: Re: Content-type: html and images ?
in thread Content-type: html and images ?

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Content-type: html and images ?
by Anonymous Monk on Feb 10, 2003 at 15:47 UTC
    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
      ( ... a web tutorial on CGI used print STDOUT)

      Which web tutorial was this? In my experience a tutorial that makes a mistake like that will often make many other (more serious) mistakes and should probably be avoided.

      I still don't get how my image path is fed to the show_pic.cgi

      I think we all pretty much assumed that the image path would be hard-coded in the CGI program.

      Must I access the database in show_pic.cgi rather than in the script that generates the html ?

      Now I'm a little confused. What do you need to access the database for?

      I was suggesting a program like this:

      #!/usr/bin/perl use strict; use warnings; use CGI ':standard'; if (param('action') eq 'showImage') { # code to open the image file and print contents } else { # code to print the HTML page # this includes an image tag that links back to this # program with the parameter "action=showImage" }

      If that's not what you're thinking of then we've been talking at cross-purposes.

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

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