K
Kati
I'm trying to get a PDF to download from a web location, instead of making
browsers display it with whatever PDF reader is configured to their
browser. So I tested the following code, placing the PDF file and the below
script in the cgi-bin:
#!/usr/bin/perl
print "Content-Type: application/force-download\n";
print "Content-Disposition: attachment\; filename=myFile.pdf\n";
print "Content-Length: 340\n";
print "Content-Description: PDF document\n\n";
open (myFile, "myFile.pdf");
print <myFile>
The above works, as far as it prompts browsers to download the file, or
to launch in a manually specified application.
However, after it downloaded, the file is corrupted for some reason and
does not open.
Could anyone who knows kindly point out what I might be doing wrong?
browsers display it with whatever PDF reader is configured to their
browser. So I tested the following code, placing the PDF file and the below
script in the cgi-bin:
#!/usr/bin/perl
print "Content-Type: application/force-download\n";
print "Content-Disposition: attachment\; filename=myFile.pdf\n";
print "Content-Length: 340\n";
print "Content-Description: PDF document\n\n";
open (myFile, "myFile.pdf");
print <myFile>
The above works, as far as it prompts browsers to download the file, or
to launch in a manually specified application.
However, after it downloaded, the file is corrupted for some reason and
does not open.
Could anyone who knows kindly point out what I might be doing wrong?