Re: Displaying files

From: Date: Thu, 14 Aug 2008 20:50:09 +0000
Subject: Re: Displaying files
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-278091@lists.php.net to get a copy of this message
On 14 Aug 2008, at 21:29, 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); ?>
That simply means it can't open the file. Make sure the machine this is running on has everything it needs to access that UNC filename. -Stut -- http://stut.net/

« previous php.general (#278091) next »