Re: Streaming Files?

From: Date: Sun, 27 Apr 2003 13:34:11 +0000
Subject: Re: Streaming Files?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145416@lists.php.net to get a copy of this message
On Sun, 2003-04-27 at 06:06, -Swordfish- wrote: > I have recently become aware that you can use PHP to stream files to users, > which most people use to protect the location of file on their server. Could > anyone point out to me how to do this? > First thing you need to do is send the user the right header, i.e.: <?php // make sure the file starts with the <?php or this won't work! header('Content-Type: something'); readfile('thefile'); // can be a web address, sends the file to the user ?> that will make whatever file you readfile in look like the web page. So if you wanted to display a PDF you could use Content-Type: application/pdf. I don't know most of the mime types off of my head, I do know that running through the php.net documentation on most of that will tell you what you need to know. And, there is a mime type called, octel/stream -- or something like that -- which allows you to force the download of the file. -Dan Anderson

« previous php.general (#145416) next »