Why don't you just do
print qq~<a href="http://my.host.com/name_of_file.xxx">Click to get file</a>~;
and let the browser handle the rest for you.
At 16:12 06.07.2001 -0400, [EMAIL PROTECTED] wrote:
>This problem might not be entirely related to Perl, but I'm pretty sure
>Perl can help solve it.
>
>Here is the thing :
>
>I want to be able to download a file (any kind of file) directly from my
>browser. I'm using this code below :
>
>#!/usr/bin/perl
>
>my $size = 19456 # 19k * 1024;
>my $fileName = "budget.xls"; # name of the file
>my $file = "../files/edi/kfred/200104311315547.xls"; # location of the
>file on the server
>
># Send the header
>print "Content-Type: application/octet-stream\n";
>print "Content-Disposition: attachment;filename=$fileName\n";
>print "Content-Length: $size\n\n";
>print read_file($file); # read the file from the server
>
>sub read_file {
>my($fname) = @_;
>my($content);
>open(FILE, "<$fname") || return '';
>while(<FILE>) { $content .= $_; }
>close(FILE);
>$content; }
>
>It works well with Netscape 4.7 but IE 5.5 gives me a problem.
>
>Let say I'm on a page called test.html. The only thing this page does is
>offer a link to the script above (download.pl). If I click on the link
>Explorer will ask me what I want to do with the file (since I've put the
>application/octet-stream Content-type) :
>
>"Save it to disk or open it"
>
>But if I choose to save it it will save test.html AND NOT budget.xls as it
>should!
>
>On the other hand, if I call download.pl directly from the location bar or
>if I make test.html automaticly open a new window on load
>[ onload=void(window.open('download.pl')) ] it does the trick!?
>
>Opening a new window would not be such a problem if I wouldn't get the
>"Page cannot be displayed" message in this new window, wich is not very
>pretty... And calling the script from the location bar is not very
>usefull, since what I want is to have a list of all my files in my browser
>window and simply be able to click on one to download it to my disk.
>
>Anyone can Help ? If you want more information to help just ask.
>
>Thank you very much for your time.
>
>Frédéric Fortin,
>[EMAIL PROTECTED]
>TPC Communications
Aaron Craig
Programming
iSoftitler.com