[thelist] http download problems

Keith cache at dowebs.com
Fri Nov 9 16:55:46 CST 2001


> 
> I want my user to be able to download a file from a web page. I don't
> have access to FTP, and so use http. I don't want spreadsheets, gifs
> and pdfs or executables to be displayed in, or launched by the
> browser, I want them to download. I can't control the user's
> preferences. Suggestions? Thanks! -- 

Perl solution:
point your href to a script with:

$page_name = give it any name you want
$file_name = the path to the file

print "Content-Type: application/x-unknown\n";
print "Content-Disposition: attachment; 
filename=$page_name\n\n"; 
open(R,"$file_name");
while(<R>){print}
close(R);

[the second print line from Content_Disposition thru to \n\n needs to 
be on one line]

IE & NN on win32 will look at the file's structure to determine the 
application to use for running the file and prompt to either run the 
file or save it to disk. Don't know about other browsers on other 
OSs.

keith




More information about the thelist mailing list