Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you change the filename of a PHP page at runtime?

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
This is a strange question I KNOW, but here is my situation...

I am displaying PDFs in a browser, pulling them from a mySQL database (this is a very secure site). This is the code that displays the PDF in the browser:

Code:
header("Content-type: application/pdf");
print(base64_decode($row["pdfFile"]));

$row["pdfFile"] is a BLOB field in the mySQL db.

This works fine when used in Internet Explorer or any browser with an Acrobat plug-in installed, but for people like Mozilla users, they are prompted with how they would like to treat the file (in my case, I use Mozilla and am asked to open with AcroExch).

So the problem is that users without a browser plug-in for Acrobat won't be able to view these, since it saves to their hard drive as a php file.

Any ideas?? Help is very much needed and would be greatly appreciated. Thanks!
 
Wow... that works perfect! Thanks! Man... kind of embarassing that the example was right there on the php.net page. Thanks for pointing that out.

Now the only question is... how do I redirect or close that browser window after the user downloads or opens the PDF? (the browser window just remains onscreen and blank) This problem isn't too much of a concern, but it would be nice if I could figure it out.
 
Dusty-

If your users use explorer (....ugh) it wont open a blank window like mozilla does. I think of that as a lacking on explorer or mozilla or adobe, not you. I know that one of the browser extensions that I run is called "DisableTargetsForDownloads" or something like that, and it was written to prevent that annoying window from opening up whenever you download a file that is pointed at a specific window.

The plugin is available on firefox's website

Robert Carpenter
"You and I have need of the strongest spell that can be found to wake us from the evil enchantment of worldliness." - C.S. Lewis (The Weight of Glory)

robert (at) robertcarpenter (dot) net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top