Re: Displaying files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14 Aug 2008, at 21:06, Dan Shirah wrote:

Who needs PHP... :)

The following will open a new browser window and load the href in it.

<a href="http://examples.com/123.xls"; target="_blank">Open It!!!</a>

If that isn't what you are looking for, please give a little more details.


You're killin' me, Jim! :)

I need to open the file from the server, using PHP. I already know how to open it using HTML and Javascript, but those methods cannot be used for this
section of my application.

I need to call and open the document in the browser window using PHP.

Example: If I was going to do it with Javascript I would just use something
simple like this;

function open() {
window.open('open.php');
}

Or, if I was going to use HTML I would use something simlar to what you
posted.

How can I achieve that same functionality using only PHP? Or is it not
possible?

You need to know the mime type for the file you're serving. Call header('Content-Type: x/y'); where x/y is the mime type. Then call readfile('/path/to/file/on/server'); to output the file to the browser.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux