PHP - How do I know if an X-Sendfile is available and installed?

Basically, I would like to send the X-Sendfile header to the browser to send the file, but I do not want to call it if the X-Sendfile is not available or is installed on the server. How can I check this in PHP? Or if it is impossible to verify in PHP, than to verify that it is installed PERIOD? I would prefer to check for the presence of the X-Sendfile in PHP, since it would be easier for me to do this, since it is part of a package that will work on other sites and servers ... Perhaps if I just use this with the PHP function header, will it return something if not installed ??

Thanks guys:)

+5
source share
4 answers

APACHE mod_xsendfile X-Sendfile

, mod_xsendfile APACHE, apache_get_modules().

, .

+6
+1

Try the following:

    if (in_array('mod_xsendfile', apache_get_modules())) {
        header("X-Sendfile: $file");
    } else {
        error_log("Warning! mod-xsendfile is NOT INSTALLED - sending file the old fashion way.....");
        header('Content-Length: ' . filesize($file) );
        print file_get_contents($file);
    }
0
source

This is not true. If XSendFile is not set to On For the appropriate location, but the module is loaded, it will erroneously assume that using xsendfile is available, although it is not.

0
source

All Articles