views:

1127

answers:

2

I can't seem to find much documentation on x_sendfile or example code for PHP (there is some rails code). Anyone use it before and would mind giving a quick snippet of code and a brief description?

+3  A: 

X-Sendfile is an HTTP header, so you want something like this:

header("X-Sendfile: $filename");

Your web server picks it up if correctly configured. Here's some more details:

http://blog.adaniels.nl/articles/how-i-php-x-sendfile/

Don Neufeld
+1  A: 

If tweaking the web server configuration is not an option, consider PHP's standard readfile() function. It won't be quite as fast as sendfiling, but it will be more widely compatible. Also note that when doing this, you should also send a Content-Type header at the very least.

Garrett Albright