ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a web page that has links to a php script that sends pdf files to the browser when clicked.
The links are like this:
Code:
<a href="getfile.php?id=1201234">
The files sent are shown embedded in the browser, which is what I want.
The problem is: the title of the browser window or tab in which the pdf file is opened is "getfile.php?id=1201234"), and not the actual file name of the pdf file.
Is it possible to send the file by a php script in a way that the window/tab title becomes the filename and not the link by which it has been accessed?
I have a web page that has links to a php script that sends pdf files to the browser when clicked.
The links are like this:
Code:
<a href="getfile.php?id=1201234">
The files sent are shown embedded in the browser, which is what I want.
The problem is: the title of the browser window or tab in which the pdf file is opened is "getfile.php?id=1201234"), and not the actual file name of the pdf file.
Is it possible to send the file by a php script in a way that the window/tab title becomes the filename and not the link by which it has been accessed?
Thank you, it is really a nice solution, but, since a pdf is not html content, it might not work.
I think I have tried that the first time, and failed with both firefox and ie. Just to be sure, I will recheck it tommorrow.
I think, however, that I have just figured out an other solution using apache mod_rewrite to trick the browser (or the embedded acrobat reader?):
Links should be formed like:
"/files/<file id>/<filename>.pdf"
and the browsers (or acrobat reader?) would be happy to put <filename>.pdf into the window title.
The php script would not be that happy with that request, actually, it would not even see it, but here Apache could help by rewriting it to:
"/getdoc.php?id=<file id>"
and the php script would now be glad to serve the file based on the file id.
This rewrite rule might do the trick, I suppose:
"RewriteRule ^/files/([^/]+)/[^/]+.pdf$ /getdoc.php?id=$1"
I know, it is a really ugly solution, but it might work. I will also try it tommorrow.
It looks like browsers do not respect beauty (or the sense of beauty of "gurus"), because the "<a ... title=..>" thingy does not work .
However, the rewrite thingy works like a charm.
Thank you for your attention.
Edit:
Well, actually, it turned out that there is much room for improvement.
I have just noticed that $_SERVER['REMOTE_USER'], $_SERVER['AUTH_USER'], $_SERVER['LOGIN_USER'] and such environment variables are sometimes all empty in the getdoc php script when using mod_rewrite. For some pdf's they are empty, for others, they are not. And I cannot figure out what makes the difference.
So environment variable $_SERVER['SUCKING_DEVELOPER'] is presently filled with my name, as a consequence of not being able to use ntlm_auth along with mod_rewrite reliably.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.