in reply to return image from CGI scrript error

print "Expires: Fri, 30 Oct 1998 14:19:41 GMT\n";

Hrm, you're sending an Expires date of about five years ago. Just how that will be handled is probably browser-specific, but I suspect this is your problem. Don't hardcode the expire data. Instead, use Date::Manip (or a similar module) to add a certain ammount of time to the current data.

Also, you're creating more work for yourself and using memory unnecessarily. Instead of buffering the image, print it out as you get it:

open IMAGE, "e:/image1.png"; my $buff; while(read IMAGE, $buff, 1024) { print $buff; } close IMAGE;

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

:(){ :|:&};:

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: return image from CGI scrript error
by bear0053 (Hermit) on Oct 21, 2003 at 16:05 UTC
    the reason for the old expiration is i don't want the image to be cached...is there a better way of doing this?

      Yes.

      Pragma: no-cache Cache-control: no-cache

      Which should work in all major browsers. See also: Issuing Correct HTTP Headers on perl.apache.org.

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      :(){ :|:&};:

      Note: All code is untested, unless otherwise stated