Re: Downloads, headers and binary data
| From: | Rick Hodger | Date: | Fri, 19 Jan 2001 13:53:28 +0000 |
| Subject: | Re: Downloads, headers and binary data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-35622@lists.php.net to get a copy of this message | ||
"Juan Germano" <droctulft@yifan.net> wrote in message
news:004b01c081f3$46be8160$ddf90dd1@juangerm...
> Hi. I'm trying to write a script to download a mp3 file. I did this:
>
> $filesize=filesize($filename);
> header("Content-disposition: attachment;filename=".basename($filename));
> header("Content-type: application/octetstream");
> header("Content-Transfer-Encoding: binary");
> header("Pragma: no-cache");
> header("Expires: 0");
> header("Content-Length: $filesize");
> readfile($filename,$filesize);
>
> I began with the first two headers but the problem is that the script
works
> fine with
> text files but I get shorter files than the originals with mp3s, so I
added
> the rest trying to solve the problem.
> So I tryied
>
> $fp=fopen($filename,"r");
> fread($fp,filesize($filename));
> fclose($fp);
Try this, only change your fread line like so:
echo fread($fp,filesize($filename));
I have to do this to put out an image with a image/vnd.wap.wbmp header, and
it works for me.
--
Rick Hodger