RE: Content-Disposition

"Earle Ake" <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <B72822CC390B459DB6B7F974057AFEDC@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:[email protected]] 
Sent: Saturday, January 21, 2012 7:02 PM
To: [email protected]
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 $/; <ZIP> };

    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!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.