Hey,
I have a mod_perl question. When the user clicks on a link I want them to be able to download a file. Below is the code I use to do it. It works fine. However, I want to make sure I am using mod_perl to it fullest, so I want to convert some of the statments to more mod_perlish (hope that makes sense )
This is the middle part of my code
The part I think I can change is the sending of the headers:
$r->print("Content-Type: application/vnd.ms-excel\n");
$r->print("Content-Transfer-Encoding: binary\n");
$r->print("Content-Disposition: attachment; filename=\"$fileName\"\n\n");
I think I would change them to:
$r->content_type("application/vnd.ms-excel");
$r->content_encoding("binary");
But what about $r->print("Content-Disposition: attachment; filename=\"$fileName\"\n\n");
Also, am I sending the file correctly??
Thanks for the help.
Later
I have a mod_perl question. When the user clicks on a link I want them to be able to download a file. Below is the code I use to do it. It works fine. However, I want to make sure I am using mod_perl to it fullest, so I want to convert some of the statments to more mod_perlish (hope that makes sense )
This is the middle part of my code
Code:
my $directory = $ENV{"MMS_TEMPORARY_DIRECTORY"};
my $path = $directory.$fileName;
#sending our headers
$r->print("Content-Type: application/vnd.ms-excel\n");
$r->print("Content-Transfer-Encoding: binary\n");
$r->print("Content-Disposition: attachment; filename=\"$fileName\"\n\n");
#creating the excel file. Creates an excel file at $path
res_report::createExcelFile(\$results,\@titles,\$path,\$header);
#opening our file so we can send it to the client
my $XLS = Symbol::gensym();
open $XLS, "$path" or die "Can't open $path: $!\n";
#setting binmode so the client knows it is binary
binmode( $XLS );
#sending the file
$r->send_fd($XLS);
#close our file off
close($XLS);
The part I think I can change is the sending of the headers:
$r->print("Content-Type: application/vnd.ms-excel\n");
$r->print("Content-Transfer-Encoding: binary\n");
$r->print("Content-Disposition: attachment; filename=\"$fileName\"\n\n");
I think I would change them to:
$r->content_type("application/vnd.ms-excel");
$r->content_encoding("binary");
But what about $r->print("Content-Disposition: attachment; filename=\"$fileName\"\n\n");
Also, am I sending the file correctly??
Thanks for the help.
Later