Re: FN-FORUM: PHP Download script
date posted 10th January 2008 10:08
Juraj Seffer wrote:
> On 9 Jan 2008 08:35:43 -0000, Steven Lavine [EMAIL REMOVED] wrote:
>
>> I'm having a slight problem with a PHP download script that I am helping
>> a client with.
>>
>
> This is what I use:
>
> header("Expires: Mon, 26 Jul 2057 05:00:00 GMT");
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header('Content-type: image/jpeg');
> echo readfile($path);
>
I've had problems with readfile() in the past when sending large files,
as PHP was attempting to allocate a massive buffer for the file and
failing. This was on an old version of PHP 4, not sure if it's still the
case in later versions, but worth bearing in mind if your code will run
in different environments. It's discussed a bit on http://php.net/readfile.
cheers,
Richard