PHP File Serving using X-Sendfile
I finally solved this problem with the use of X-Sendfile
apache module
<?php
if (file_exists($file))
{
// send the right headers
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Content-type: ' . $fmime);
header('Content-Length: ' . filesize($file));
// Make sure you have X-Sendfile module installed on your server
// To download this module, go to https://www.apachelounge.com/download/
header('X-Sendfile: ' . $file);
exit;
}
else
{
die('File loading failed.');
}
X-Sendfile works for all folder and not just XSendFilePath
Try with the XSendFilePath directive
XSendFilePath allow you to add additional paths to some kind of white list. All files within these paths are allowed to get served through mod_xsendfile.
PHP - How to find out if X-Sendfile is available and installed?
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.
PHP can't display image using X-SendFile and jpeg headers
The above code did work, it was x-sendfile which was not configured properly in apache
Related Topics
Simple HTML Dom: How to Remove Elements
Symfony 3.4 Use View Inside My Bundle
How to Alias a Table in Laravel Eloquent Queries (Or Using Query Builder)
Geo-Search (Distance) in PHP/MySQL (Performance)
Convert PDF to Jpeg with PHP and Imagemagick
Calculate Difference Between Two Dates Using Carbon and Blade
Mcrypt_Encrypt to Openssl_Encrypt, and Openssl_Zero_Padding Problems
Check Whether or Not a Cidr Subnet Contains an Ip Address
Naming Convention Issues When Using Codeigniter in Windows and Linux
Doctrine Query Language Get Max/Latest Row Per Group
Php7.1 JSON_Encode() Float Issue