[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Another step in the Glue...



On Thu, 19 Jun 1997, Strider wrote:

> >According to Strider:
> >>
> >> Well, I worked out that I need to send a binary file (the gif) back to
> >> WebStar. How do I do THAT? I pretty much need to print a binary. Can I use
> >> a pipe | to pipe it straight to print from open, or put it into a variable
> >> and then print it (which so far hasn't worked)?
> >>
> >> #!perl
> >> # takes input:
> >>http://www.clarityconnect.com/counter.count$cci/clarityconnect
> >> print "HTTP/1.0 200 OK\nContent-type: image/gif\n\n";
> >> open HANDLE, "</gifs/gifone.gif";
> >> binmode HANDLE;
> >> $gif = HANDLE;
> >> close HANDLE;
> >> print $gif;
> >> print "\n";
> >>
> >> This is what I've got so far, and it doesn't work.
> >> I truely hope I haven't done something stupid like set the gif to output,
> >> rather than input.
> >
> >This is _really_ not a MacPerl question - it's either a
> >Perl question or a CGI question - but not a MacPerl
> >question.  :-)
> >
> >That said - You need to send back the proper CGI command:
> >
> ><img src="gifs/gifone.gif">
> >
> >This will cause the browser to then ask for the image to be
> >sent.  I do it all of the time.  :-)
> >
> >Also - you can not open a binary file (like a gif file) as
> >a text file and expect anything to work.  Binary to
> >binary.  Text to text.  If you want to work with a binary
> >file, then you have to treat it as such.  You can send a
> >GIF file by doing the following also:
> >
> >@fileStat = stat "gifs/gifone.gif";
> >sysopen( THEFILE, "gifs/gifone.gif", O_RDWR ) || die $!;
> >sysread( THEFILE, $iobuf, $fileStat[7] );
> >close( THEFILE );
> >
> >$iobuf will then correctly contain the information from the
> >binary file and can be sent.  However, you still have to
> >tell the server how to send this properly (which you have
> >with the image/gif stuff).
> >
> >I hope this helps.  I've always just used the
> >"Content-type: text/html" with the '<img src="xxxxx">' and
> >have never had any kind of a problem with getting an image
> >to show up correctly.  :-)
> 
> 
> Thanks much. As much as it might not be a MAC perl problem, I just feel
> more comfy and cooshy in a mac-friendly environment. =)
> 
> Thanks,
> Seraph
> 

Also, to further stray from MAC perl :)  You can also do something like:
Use this for your html tag:
<IMG SRC="blah.cgi">

where blah.cgi has:

print "Location: http://some.site/image.gif\n\n";

(That's instead of the Content-type line)

Hope this helps....

Nam

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch