Transfering PDF's without PDFLib

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
musashi
Forum Commoner
Posts: 39
Joined: Tue Jul 23, 2002 12:51 pm
Location: Santa Cruz - CA

Transfering PDF's without PDFLib

Post by musashi »

Does anyone know if this is possible?

I have a simple rountine setup, but the issue is that since the file extension to the php program is .php IE seems to be confused as to what to do. So it's solution is to just download the contents of the file and display it in a text editor. When, my hope is to have it realize this is a pdf file and use Acrobat.

Any ideas?

Here is the code:

Code: Select all

<?php
header("Content-Type:  application/pdf");
$fp = fopen("tutorial.pdf","r");

fpassthru($fp);

fclose($fp);
?>
Greatly appreciate the help!
User avatar
gyardleydn
Forum Commoner
Posts: 27
Joined: Tue Dec 03, 2002 8:27 am

Post by gyardleydn »

If you are using apache, you could create a directory with an .htaccess file with the following entry

AddType application/x-httpd-php .pdf

Then you could use php with a file that has a pdf extension to provide security, or whatever reason you don't want to provide direct access, but still provide a pdf extension for browsers that ignore type headers.
User avatar
hyper_st8
Forum Newbie
Posts: 20
Joined: Mon Aug 18, 2003 5:27 am
Contact:

Post by hyper_st8 »

header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=foo.pdf");
readfile("tutorial.pdf", 'r');

Would work. I think...
Post Reply