RE: Content-Disposition

2012-01-21 Thread Earle Ake
I have done it before using something like:

 

print "Content-Disposition:attachment;filename=$download_name\n";

 

So maybe try:

 

$r->header_out( 'Content-Disposition' => 'attachment; filename="' .
$download_name . '"');

 

 

  _  

From: cfaust-dougot [mailto:cfa...@doyougot.com] 
Sent: Saturday, January 21, 2012 7:02 PM
To: modperl@perl.apache.org
Subject: Content-Disposition

 

Hello,

 

I'm guessing there is a real simple answer to my question but as uasual, I
can't find it :)

 

Simply put I'm trying to create a Zip file and push it to the user using a
filename I've defined. Everything works except the name of the file that
comes up in the browser dialog. It always defaults to the script/location
name. I thought that all I needed was Content-Disposition but that doesn't
seem to be working.

 

CentOS 5.5, mod_perl 2.0.4, apache 2.2.3 (both mod_perl and apache should be
backported via yum update).

 

my $zip = Archive::Zip->new();

my $member = $zip->addString('yadda yadda yadda');

my $download_name = 'download.zip';

if ( $zip->writeToFileNamed('someothernamed.zip');

open(ZIP, 'someothernamed.zip') or die "could not open sonz $!";

binmode ZIP;

my $output = do { local $/;  };

close(ZIP);

$r->content_type('application/zip');

$r->header_out( 'Content-Disposition' => 'inline; filename="' .
$download_name . '"');

$r->send_http_header;

print $output;

return Apache2::Const::OK;

}

 

I tried setting the header before the content_type and with and without
"send_http_header". What am I doing wrong? How can I get the user to be
prompted to save the file as "download.zip??

 

TIA!

 

 



Content-Disposition

2012-01-21 Thread cfaust-dougot
Hello,
 
I'm guessing there is a real simple answer to my question but as uasual, I 
can't find it :)
 
Simply put I'm trying to create a Zip file and push it to the user using a 
filename I've defined. Everything works except the name of the file that comes 
up in the browser dialog. It always defaults to the script/location name. I 
thought that all I needed was Content-Disposition but that doesn't seem to be 
working.
 
CentOS 5.5, mod_perl 2.0.4, apache 2.2.3 (both mod_perl and apache should be 
backported via yum update).
 
my $zip = Archive::Zip->new();
my $member = $zip->addString('yadda yadda yadda');
my $download_name = 'download.zip';
if ( $zip->writeToFileNamed('someothernamed.zip');
open(ZIP, 'someothernamed.zip') or die "could not open sonz $!";
binmode ZIP;
my $output = do { local $/;  };
close(ZIP);
$r->content_type('application/zip');
$r->header_out( 'Content-Disposition' => 'inline; filename="' . 
$download_name . '"');
$r->send_http_header;
print $output;
return Apache2::Const::OK;
}
 
I tried setting the header before the content_type and with and without 
"send_http_header". What am I doing wrong? How can I get the user to be 
prompted to save the file as "download.zip??
 
TIA!