Skip to content
Advertisement

PHP(32-bit) 2GB Range Download

I have the following problem: I have a php webpage which:

  • is running on a raspberry pi(32bit)
  • should deliver files for download which are bigger than 2 GB
  • files are access protected, which means, that you only are allow to download the file depending on a condition in the php code
  • must support HTTP range requests

I have a solution for deliver files with range requests from php, but in this solution I’m using fseek, which doesn’t work for files bigger that 2GB and I can not figure out how to solve that problem.

I’m using nginx and php7-fpm if this is relevant for you.

Advertisement

Answer

I found a solution which solves the problem for me. Instead of trying to send the file from the php script, I use an feature of nginx.

Nginx offers a possibility to redirect a request to an existing file, but only from an internal redirect via the “X-Accel-Redirect” header.

Documentation: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/

It seems to be possible with other severs too, but it definitiv work with nginx.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement