Re: Displaying files

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

 



On Aug 14, 2008, at 3:29 PM, Dan Shirah wrote:


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



Stut, trying that method gives me the following: PHP Warning: readfile(
\\server\folder\file.xls) [<a
href='function.readfile'>function.readfile</a>]: failed to open stream:
Invalid argument on line 44

Here's my code.  Line 44 is where it stated readfile()
This document is located on a seperate server.


<?php
$folder = $_GET['folder'];
$file = $_GET['file'];

$filename = "\\\\server\\".$folder."\\".$file.".xls";
header("Content-Type: application/x-msdownload");
readfile($filename);
?>

This won't address the permissions issue, but I ran into a similar problem where IE wouldn't open the file unless 'exit;' was present. You may want to add:

<?php
readfile($filename);
exit;
?>

Cheers,
~Philip


--
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