I want to give a link to a postscript file, but first I want to make a script that will monitor the downloads of this file. The link has to be 'direct' so I added .ps
extension to be interpreted by PHP. In the begining the script opens the text file, writes some information and then I don't know what to do.
Basically I have something like this (file apendix.ps
):
header('Content-type: application/postscript');
header('Location: appendix.ps');
but then, the link to this file has to have different name, so eventually I'm serving different file than in 'direct' link.
Is it possible to write a script appendix.ps
which does something in the begining and then serves real appendix.ps
file?
regards
chriss
You can use readfile:
header('Content-type: application/postscript');
readfile('appendix.ps');
You also may want to send a "Content-Disposition" header to hint to the user agent how its intended to be displayed.
If you want to suggest to open it in a new window, Ie: trigger a download action:
header('Content-Disposition: attachment');
If you want to suggest to display it in the browser if it can:
header('Content-Disposition: inline');
Noting of course these are just suggestions and the browser may not play ball or even be able to, but they're handy to have.