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, 3:48 am
Please log in for more thread options
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?

Thanks.

Posted by Frank Seitz on March 11, 2008, 4:23 am
Please log in for more thread options
howa wrote:
> In order to hidden the real path, I send the png file via CGI, e.g.
>
> [Perl program]
>
> Any faster/better method?

An alias (HTTP server directive).

Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Posted by howa on March 11, 2008, 11:24 pm
Please log in for more thread options
On 3=D4=C211=C8=D5, =CF=C2=CE=E74=95r23=B7=D6, Frank Seitz <devnull4...@web.=
de> wrote:
> howa wrote:
> > In order to hidden the real path, I send the png file via CGI, e.g.
>
> > [Perl program]
>
> > Any faster/better method?
>
> An alias (HTTP server directive).
>
> Frank
> --
> Dipl.-Inform. Frank Seitz;http://www.fseitz.de/
> Anwendungen f=A8=B9r Ihr Internet und Intranet
> Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel


Posted by howa on March 11, 2008, 11:27 pm
Please log in for more thread options
On 3$B7n(B11$BF|(B, $B2<8a(B4$B;~(B23$BJ,(B, Frank Seitz
> howa wrote:
> > In order to hidden the real path, I send the png file via CGI, e.g.
>
> > [Perl program]
>
> > Any faster/better method?
>
> An alias (HTTP server directive).
>

Hi,

A path is mapped to many files, so the real file is only know when
client request for the page.

I have heard something like x-sendfile but we don't have this option
to use, so I must send thru perl.

Thanks.

Howard


Posted by xhoster on March 11, 2008, 12:49 pm
Please log in for more thread options
> 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

--
-------------------- 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.

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