in reply to File downloader
Disposition headers are very important when doing this. You can force the file to open in different ways. In this example, I'm forcing PPT to open the file in PPT outside of the browser and in slideshow mode. (If I recall correctly - it's a while since I looked at this system in action.)
Obviously you'll write a much more elegant file-request-to-filename converter than the trash I've included here for this example.
$presentation_1 = "./mypath/my_file_1"; $presentation_2 = "./mypath/my_file_2"; $presentation_3 = "./mypath/my_file_3"; $download_filetype = ".pps"; #get_and_process_form; my $query = new CGI; @form_field_names = $query->param; foreach $field (@form_field_names) { $form_values{$field} = $query->param($field); } $request = $form_values{'report'}; if ($request eq "aaaa") {$presentation = $presentation_1;} elsif ($request eq "bbbb") {$presentation = $presentation_2;} else {$presentation = $presentation_3;} open(FILE, $presentation) or dienice("cannot open file $presentation : + $_[0] $!"); @LINES = <FILE>; close(FILE); $filename = join('_', $form_values{'report'}, $form_values{'language'} +, $form_values{'year'}); $filename = join('', $filename, $download_filetype); print "Content-type: application/vnd.ms-powerpoint\n"; print "Content-Disposition: attachment; filename=$filename\n\n"; for $i (0..$#LINES) { print $LINES[$i]; }
|
|---|