faqts : Computers : Programming : Languages : Perl

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

47 of 59 people (80%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

replacing the <a href=download file by <a href=cgi which is sending the file, the filename is changed to the script filename

Jul 28th, 2000 03:57
Kirederf,


Thanks to 
vincent.oneto
who helped me

My goal was sending a file to download via a cgi
to do so you have to tell the browser the following things

print "Content-type: application/octet-stream\n";
print "Content-Length: $size\n";
print "Content-disposition: filename=$filename\n\n";
open(FILE, "<$filepath") || die;
while(<FILE>)
{	print $_;}
close(FILE);

first you give a type (I don't know if this one is the good one but It 
works on every browser I tested on)
Then if you have it you give the length
then the content-disposition which will be the default name of your 
downloaded file in the "save as" window.
Hope this will help for others.