Hello,
----- Original Message -----
From: "Mumia W." <[EMAIL PROTECTED]>
To: "Beginners List" <beginners@perl.org>
Sent: Saturday, October 14, 2006 12:09 PM
Subject: Re: Automatied downloads
On 10/14/2006 06:05 AM, Mike Blezien wrote:
Hello,
Hello
[ php script snipped ]
###############################################################
I've been trying to convert this to a Perl script with not much luck. Was
hoping to get some tips on how to convert this to Perl or a similar method
using Perl so when the link is clicked on, the file will be automatically
downloaded instead of clicking on the link to do a "Save As".
Can you show us your Perl program for doing this?
Most likely it's just a matter of setting the Content-Disposition the way you
did before.
This is what I've come up with so far, not tested yet tho:
# code snip
##################################################
use CGI qw(:standard);
use strict;
my $bytes_read =0;
my $size ='';
my $buffer ='';
my $download_dir = '/path/to/downloadable_files';
my $original_file = 'some_file.pdf';
$file = "$download_dir/$original_file";
open (ZIP, "<$file") || die "Can't open $file: $!";
# Not sure if this should be a 'inline' or 'attachement' here
print header(-type=>'application/octet-stream', 'Content-Disposition'=>"inline;
filename=$original_file");
binmode(ZIP);
while ($bytes_read=read($file,$buffer,4096))
{
$size += $bytes_read;
print $buffer;
}
close (ZIP);
# End snip
#####################################################
but I think this should do the job ... maybe? Or is there a better way to
accomplish this?
TIA,
Mike
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>