Re: file access(mpeg) only for authenticated people

From: Date: Wed, 07 Mar 2001 10:25:32 +0000
Subject: Re: file access(mpeg) only for authenticated people
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42886@lists.php.net to get a copy of this message
Hey, Well sure there is: $fp = fopen($filename, 'r') or die('damn'); $read = fread($fp, filesize($filename)) or die('damn'); $filestr = basename($filename); header("Content-Disposition: attachment; filename=$filestr"); header("Content-Type: application/octet-stream"); echo $read; exit; Neat And Clean! Your authentication can be done above that piece of code, you then open the file, read it through send the filename download as $filestr, and the contents $read. Simple! --- Thorsten Gutermuth <thorsten.gutermuth@ic.ac.uk> wrote: > Hi! > I'm trying to make some mpegs available only to > people who authenticated > themselves using php. But all the solutions I found > somewhat unpleasant > because I uses chmod to set the file attributes to > u=rw and then > used either > i) > readfile("ftp://name:password@server/path//test.mpeg"); > > or > > ii) header ("Location: > ftp://name:password@server/path/test.mpeg"); > > But in case > i) the browser asks if I want to download the file > or view it. If I choose > view the browser suggests to save the movie as > myscript.php and if I choose > view it ´doesn't display anything. > > ii.) the browser displayes my username and password > in the statusbar > > And in both cases it downloads the whole file(I > guess cause I use ftp) > before starting the mpeg programm(where nothing > happens afterwards in case > i) > > Is there a better way? ´Like telling the server via > http my login data and > sending the file to the users browser? > > Thanks > Thorsten > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-general-unsubscribe@lists.php.net > For additional commands, e-mail: > php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== To find out more about me : http://www.geocities.com/mimodit My bookmarks are available @ http://mukul.free.fr __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/

« previous php.general (#42886) next »