|
Posted by Richard Lynch on 05/12/05 01:14
On Wed, May 11, 2005 6:56 am, George Pitcher said:
> I have a system running on my main server containg separate user and staff
> interfaces to the same MySQL databases.
>
> Part of my process involves spawning off pdf front covers to a local
> directory, grabbing files from an archive on a networked pc and adding
> them
> together to ftp back to the server (which, incidentally is 70 miles away).
> My own machine runs IIS5/PHP5 and the Java classes to do the pdf joining.
>
> I have a link on a server mounted page that opens the localhost page and
> successfully prints off the pdf covers. However, on completion, the popup
> disappears and I then get a 'file open/save' dialog box which, if I 'open'
> tries to open the php file in Dreamweaver (my chosen IDE). What should
> happen is that on completion, a smarty template should be opened.
I was with you until you threw in the Smarty template at the end...
At any rate, what the browser "opens" depends on two things:
1. The headers you send.
2. The URL (Microsoft only)
If you don't like what the browser is opening to handle your output, you
need to change these two things.
1. is fairly trivial to change. You definitely want
header("Content-type: smarty/template");
only smarty/template should be, errr, whatever opens up a smarty template,
whatever that is.
You probably also need header("Content-disposition: ...") header for
broken Microsoft browser that use that ms-only made-up header.
2. is only slightly more tricky. In many cases, regardless of the headers
you send, MS IE is going to key off the URL you surf to, and fire up the
application based on the ending ".xyz" where ".xzy" is the "file
association extension" setting in MS Windows. This is a REALLY STUPID
thing that MS did with IE, but there it is.
To beat this, you basically force your URL to end with the extension that
MS Windows uses to open up whatever it is you want opened up.
For a PDF, for example, you could make the URL look like:
http://example.com/myscript.php/fool_ie.pdf
PHP (and Apache) are going to *IGNORE* the "/fool_ie.pdf" part, and run
your PHP script, but MS IE will key off of fool_ie.pdf to fire up
Acrobat/Reader.
Even this isn't fool-proof, especially if you need to add GET parameters:
http://example.com/myscript.php/fool_ie.pdf?record_id=42
and you want to support Microsoft IE 4.x for Macintosh, which will puke on
the GET parameters. [sigh]
So, to make a long story short, the SAFEST thing to do is craft a URL
which Microsoft cannot possibly screw up:
http://example.com/myscript/record_id=42/fool_ie.pdf
You can use .htaccess and ForceType to get 'myscript' to be a PHP script.
Apache will ignore the "/record_id=42/fool_id.pdf" bit, except to provide
it to PHP in $_SERVER['PATH_INFO'] which you can tear apart. Search this
list for a post on this same topic for some free code to do that fairly
nicely, if I do say so myself.
It would be nice if IE actually followed the HTTP standards for
Content-type and other headers, but this is Microsoft, and they don't
follow standards. They just do what they want and write new
(incompatible) "standards" instead. :-)
[Not that Netscape's record is all that clean either, but MS does this in
ALL their software... to the point where it's a one-company conspiracy of
incompatibility to lock-in customer (victims, really)]
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|