Re: fopen over a network

From: Date: Thu, 05 Dec 2002 00:49:28 +0000
Subject: Re: fopen over a network
Groups: php.general 
Request: Send a blank email to php-general+get-127075@lists.php.net to get a copy of this message
Thanks for the advice lads but I realise I should have been clearer. I know about header(etc..) so displaying the download dialog isn't the problem, it's how to get to the file on the file server and then open it. The file server isn't a web server. This is probably ridiculously easy so I hope I'm not wasting your time. I don't want to@use the 'right-click' option, I want something similar to@opening attachments in hotmail for example. Here's what I have anyway. <?php if (isset($_GET["fname"])){ $fpath="file://fileserver/directory/"; $fname=$_GET["fname"]; $filename=$fpath.$fname; $filelength=filesize($filename); header("Content-type: application/stream"); header("Content-Length: $filelength"); header("Content-Disposition: attachment; "); $fp=fopen($filename,"rb"); print(fread($fp,$filelength)); fclose($fp); } ?> Cheers, Dara ----- Original Message ----- From: Philip Olson <philip@cornado.com> Date: Wed, 4 Dec 2002 19:10:31 +0000 (GMT) To: Elkan <webmaster@harbornet.com> Subject: Re: [PHP] fopen over a network > > Please reread the documentation found here: > > http://www.php.net/header > > It has a pdf file as an example, modify according > to your needs. > > Regards, > Philip > > > On Wed, 4 Dec 2002, Elkan wrote: > > > Couldn't you set the Mime-Type on the server for the correct extenstion? > > > > Leif K-Brooks wrote: > > > > > Link them to a page like this to download the file: > > > > > > <?php > > > header("Content-type: application/octet-stream"); > > > //Code to display file > > > ?> > > > > > > Dara Dowd wrote: > > > > > > >Hello, > > > >I'd like a user to be able download a file from a file server on my LAN. > > > > > > > >Using <a href="file://server/directory/filename"> works ok, but > > > >this simply displays the file in the browser and I want to force the download dialog box to appear. > > > > > > > > > > > >So now i have <a href="download.php?file=filename">, and i want > > > >to do something like > > > >fopen("file://server/directory/filename",rb") but i just get an > > > >invalid argument warning. > > > >Am i on the right track?Is there a way around this? > > > > > > > >Cheers, > > > >Dara > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > The above message is encrypted with double rot13 encoding. Any unauthorized attempt > > > to decrypt it will be prosecuted to the full extent of the law. > > > > ----- Original Message ----- From: Philip Olson <philip@cornado.com> Date: Wed, 4 Dec 2002 19:10:31 +0000 (GMT) To: Elkan <webmaster@harbornet.com> Subject: Re: [PHP] fopen over a network > > Please reread the documentation found here: > > http://www.php.net/header > > It has a pdf file as an example, modify according > to your needs. > > Regards, > Philip > > > On Wed, 4 Dec 2002, Elkan wrote: > > > Couldn't you set the Mime-Type on the server for the correct extenstion? > > > > Leif K-Brooks wrote: > > > > > Link them to a page like this to download the file: > > > > > > <?php > > > header("Content-type: application/octet-stream"); > > > //Code to display file > > > ?> > > > > > > Dara Dowd wrote: > > > > > > >Hello, > > > >I'd like a user to be able download a file from a file server on my LAN. > > > > > > > >Using <a href="file://server/directory/filename"> works ok, but > > > >this simply displays the file in the browser and I want to force the download dialog box to appear. > > > > > > > > > > > >So now i have <a href="download.php?file=filename">, and i want > > > >to do something like > > > >fopen("file://server/directory/filename",rb") but i just get an > > > >invalid argument warning. > > > >Am i on the right track?Is there a way around this? > > > > > > > >Cheers, > > > >Dara > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > The above message is encrypted with double rot13 encoding. Any unauthorized attempt > > > to decrypt it will be prosecuted to the full extent of the law. > > > > -- For the largest free email in Ireland (25MB) & File Storage space (20MB), visit http://www.campus.ie Powered by Outblaze

« previous php.general (#127075) next »