Re: file access(mpeg) only for authenticated people
| From: | Thorsten Gutermuth | Date: | Wed, 07 Mar 2001 15:32:32 +0000 |
| Subject: | Re: file access(mpeg) only for authenticated people | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42908@lists.php.net to get a copy of this message | ||
hi!
I'm having some trouble with this. If i use an ftp address out of some
reason I'm unable to read the file(although I get a handle).(ftp server
supports passive mode)
And if I use http(without authorisation) the browser still asks if I want to
save it.(even if I use video/mpeg as Content-Type) and still displays the
name of my php script instead of the mpeg when asking what I want to do. If
I choose save it then displays the right filename.
Thanks
Thorsten
Mukul Sabharwal <mukulsabharwal@yahoo.com> schrieb in im Newsbeitrag:
20010307102532.38253.qmail@web10108.mail.yahoo.com...
> 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!