in reply to Printing inline images

You're getting garbage output because $src gets set to the binary data of the image, and then you put that directly into a HTML page.

Something along the lines of this might work better:

#!/usr/bin/perl use CGI; use LWP; use LWP::Simple; use LWP::UserAgent; $ua = new LWP::UserAgent; $q = new CGI; $url = "http://10.50.1.1/pics/topbanner1.gif"; $req= HTTP::Request->new(GET => $url); $page = $ua->request($req); if ($page->is_success) { print q->header(-type => image/gif), $page->content; } else { print $q->header(-status => 404), $q->h1('Not Found'), $q->p($page->error_as_HTML), $q->end_html; }

Replies are listed 'Best First'.
Re: Re: Printing inline images
by satanklawz (Beadle) on Jul 03, 2003 at 13:32 UTC
    Ah HA! More brains are better than one :)

    #!/usr/bin/perl use CGI; use LWP; use LWP::Simple; use LWP::UserAgent; $ua = new LWP::UserAgent; $q = new CGI; $url = "http://10.50.1.1/pics/topbanner1.gif"; $req= HTTP::Request->new(GET => $url); $req->header('Accept' => "$mime_type"); $page = $ua->request($req); if ($page->is_success) { print "Content-type: $mime_type\n\n"; print $page->content; } else { print $q->header, $q->start_html($page->error_as_HTML), $q->h1($error), $q->end_html; }

    IT WORKS! Thanks to all who helped :) I'm still looking into that proxy feature though as an option.