I would just add a link like this to your dynamiic page:
<a href="/cgi-bin/myscript.pl/logfile.txt?request=download"> Click here to download</a>
This link will call your script and pass it the name value pair request=download. If you then have the script print out the file as shown in the links you are done. The extra path info after myscript.pl gives the download file its name.
# add this to the script if ($q->('request') eq 'download') { &DownloadFile( $filepath, $filename ); exit; } sub DownloadFile { my ($filepath,$filename) = @_; my $filesize = -s "$filepath/$filename"; print "Content-disposition: attachment; filename=$filename\n"; print "Content-Length: $filesize\n"; print "Content-Type: application/octet-stream\n\n"; my $buffer; open FILE, "$filepath/$filename" or die "Oops $!"; binmode FILE; binmode STDOUT; print $buffer while (read(FILE, $buffer, 4096)); close FILE; }
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: download a file from non-web space
by tachyon
in thread download a file from non-web space
by c
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |