Hi Chris, a million thanks for the help there. That's what i thought I'd
have to do.
What I'm doing now is inspect the Range header to pull out the start and
end, and then deduce the length, and then using fopen, fseek and fread to
open the file and read from a certain offset for a certain length.
Now I have another dilemma. It's all well and good to use fread() to read
into a variable, and then echo that (or just echo(fread()) ..) but suppose
someone requests from 100-650000000 bytes of an ISO file - that's gonna
pretty quickly drag the machine down.
Basically what i'm looking for is something similar to readfile() but with
offset and length support. Any ideas ?? I suspect the answer lies in
streams, but i could be wrong.
-Dan
On Wed, 16 Jul 2003, Chris Shiflett wrote:
> --- Dan Goodes <[EMAIL PROTECTED]> wrote:
> > What I want is for the PHP script to read ALL the headers for the
> > request (in particular, RANGE headers), and then return the relevant
> > portion of the file. Can this be done fairly simply?
>
> I think you will find all header in the $_SERVER array. It is definitely
> possible to do what you're wanting, but I'm not sure exactly how simple you
> will think it is. Maybe there is some existing code someone has written that
> does this sort of thing for you, but I'm not aware of any.
>
> At most, you would just have to parse the Range header yourself to deduce what
> byte range to serve.
>
> > Also is there a way for PHP to tell apache which response code to
> > send?
>
> Yeah, this should work:
>
> header('HTTP/1.1 206 Partial Content');
>
> Hope that helps.
>
> Chris
>
> =====
> Become a better Web developer with the HTTP Developer's Handbook
> http://httphandbook.org/
>
--
Regards,
Dan Goodes : Systems Programmer : [EMAIL PROTECTED]
Help support PlanetMirror - Australia's largest Internet archive
by signing up for PlanetMirror Premium : http://planetmirror.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php