Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - How to find out if X-Sendfile is available and installed?

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

Thanks guys :)

like image 378
Solomon Closson Avatar asked Sep 02 '12 04:09

Solomon Closson


2 Answers

The APACHE module mod_xsendfile processes the X-Sendfile headers

To check if the APACHE module mod_xsendfile is available and installed on the server, you could use apache_get_modules() function.

You cannot just set the header and check if the module is installed or not.

like image 96
verisimilitude Avatar answered Sep 30 '22 12:09

verisimilitude


To get a list of apache modules and see if x-sendfile is in the list you could use http://php.net/manual/en/function.apache-get-modules.php If it's not installed, the x-sendfile header will get to the browser if it is installed, the module will filter out the header.

like image 32
rx80 Avatar answered Sep 30 '22 12:09

rx80