I have been made aware of the Accept-Range header.
I have a URL that I am calling that always returns a 2mb file. I don’t need this much and only need the last section 20-50k.
I am not sure how to go about using it? Would I need to use cURL? I am currently using file_get_contents().
Would someone be able to provide me with an example / tutorial?
Thanks.
EDIT: If this isn’t possible then what is post on about? Here …
EDIT: Ulrika! I’m not insane.
This is possible using the
Rangeheader, provided the server supports it. See the HTTP 1.1 spec. You would want to send a header in the following format in your request:This would give you the last 50,000 bytes. Adjust to whatever you need.
You can specify this header in
file_get_contentsusing a context. For example: