>> Why don't you just do print qq~
>><a href="http://my.host.com/name_of_file.xxx";>Click to getfile</a>~;
>>and let the browser handle the rest for you.
>>
>>Because in that case, files like .txt or .html would appear in the browser 
>>instead of being downloaded to my harddrive. This is not very helpfull 
>>(having those files displayed in the browser) when what I want to do is 
>>get them on my HD from one place to an other (at work and at home)...
>>
>>I need to be able to save to disk...

>Why don't you just do
>print qq~<a href="http://my.host.com/name_of_file.xxx";>Shift-click to get 
>file</a>~;
>then? :-)

If I rename the file someword.txt to someword.xxx Internet Explorer doesn't get fool 
by the extension .xxx and it opens the text file in the browser, and don't offer me 
the choice to download it.

I think the problem is that when a html file has already been open in a window browser 
it mixes up the next header that is being send or something like that. Maybe it is a 
bug with IE, but I'm pretty sure someone, somewhere has succeed in letting people 
download .txt files or .html files through their browsers...

Here again is what my code looks like : 

#!/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() { $content .= $_; } 
    close(FILE); 
    $content; } 

My problem is that there is a bug in Explorer 5.5 (and may be other version of IE). If 
I call the script above from a page called link.html Explorer will offer me the choice 
to save to disk... link.html instead of budget.xls... But if I call the script 
download.pl from the location bar or if link.html opens a new window to download.pl it 
works... Must be something wrong with the header when I call it from a link on a 
page...

Thank you again for your time and your advice

Reply via email to