Click here to get back home

Fastest way to send file to browser

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Fastest way to send file to browser howa 03-11-2008
Posted by howa on March 11, 2008, 11:24 pm
Please log in for more thread options
On 3$B7n(B12$BF|(B, $B>e8a(B12$B;~(B49$BJ,(B, xhos...@gmail.com wrote:
> > In order to hidden the real path, I send the png file via CGI, e.g.
>
> > ##############
>
> > print "Content-type:image/png\n\n";
> > my $file = "test.png";
>
> > open INPUT_FILE, "$file" or die "Couldn't open file: $!";
> > while( sysread(INPUT_FILE, $data, 10240) ) {
> > print $data;
> > }
> > close FILE;
>
> > ##############
>
> > Any faster/better method?
>
> Take a step back and do some introspection on why you want to hide the
> real path in the first place.
>
> Xho

An example would be captcha images, good reason?

Thanks.

Howard

Posted by xhoster on March 12, 2008, 2:04 pm
Please log in for more thread options
> On 3$B7n(B12$BF|(B, $B>e8a(B12$B;~(B49$BJ,(B, xhos...@gmail.com
> wrote:
> > > In order to hidden the real path, I send the png file via CGI, e.g.
> >
> > > ##############
> >
> > > print "Content-type:image/png\n\n";
> > > my $file = "test.png";
> >
> > > open INPUT_FILE, "$file" or die "Couldn't open file: $!";
> > > while( sysread(INPUT_FILE, $data, 10240) ) {
> > > print $data;
> > > }
> > > close FILE;
> >
> > > ##############
> >
> > > Any faster/better method?
> >
> > Take a step back and do some introspection on why you want to hide the
> > real path in the first place.
> >
> > Xho
>
> An example would be captcha images, good reason?

Probably not. I would expect captcha images to be either generated on the
fly or stored in a database, so there is no path to hide. Or selected on
the fly, in which case your goal is not to hide the path but to select the
path.

Given that you are going to start up Perl in the first place, I don't
see any obvious problems with our code, other than possibly a lack of
error checking on the sysread. And that the file handle you close
is different than the file handle you open.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Posted by howa on March 13, 2008, 12:39 am
Please log in for more thread options
On 3$B7n(B13$BF|(B, $B>e8a(B2$B;~(B04$BJ,(B, xhos...@gmail.com wrote:
>
> Probably not. I would expect captcha images to be either generated on the
> fly or stored in a database, so there is no path to hide. Or selected on
> the fly, in which case your goal is not to hide the path but to select the
> path.

I have cron job to generate the images from time to time, as real time
is expensive for server.
We also put the image file outside the document root, so we must send
the file using Perl.

>
> Given that you are going to start up Perl in the first place, I don't
> see any obvious problems with our code, other than possibly a lack of
> error checking on the sysread. And that the file handle you close
> is different than the file handle you open.

Thank you .

Howard

Similar ThreadsPosted
How to send a query to the browser from time to time? July 20, 2005, 9:35 am
How can I send the output of the system() command to a file and capture a string in that file June 19, 2005, 1:30 pm
Kindly help :::How can I send the output of the system() command to a file and capture a string in one of the lines in that file June 19, 2005, 1:40 pm
How to delete temporary file after displaying in browser ? October 2, 2006, 11:21 am
file does not begin with '%PDF-' - Error when searching pdfs on FireFox browser August 2, 2006, 11:02 am
use CGI::Carp qw(fatalsToBrowser) not sending file handle errors to browser March 1, 2008, 6:17 pm
Script to send file attachment with sendmail not working November 20, 2004, 7:53 pm
Fastest versions of perl? September 1, 2004, 12:16 am
Fastest Hex to Ascii routine February 8, 2006, 3:28 pm
Fastest way to find a match? March 12, 2008, 7:34 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap