Xsendfile not found

I use mod_xsendfile on Dreamhost to upload large zip files (50mb +)

I have mod_xsendfile and "XSendFile on" enabled in my .htaccess.

When i give

header('X-Sendfile: "'.$fullPath.'"'); 

using the full path to the file that runs on the server, I get a web page error message.

readfile () finds the file just fine and serves it, but the .zip files are too large to handle php.

Any help you could provide would be appreciated!

+4
source share
4 answers

I had the same problem and I was able to solve it, so maybe this solution will work for you.

First of all, you need to check the Apache error logs (for me, which are in / etc / httpd / logs). This is what I found in my:

 [Wed Sep 05 14:29:02 2012] [error] [client ?.?.?.?] (20023)The given path was above the root path: xsendfile: unable to find file: /path/to/file 

The problem was that the file I was looking for was located above the DocumentRoot (for me, / var / www / html) as defined in httpd.conf.

My solution was to create a symlink in the DocumentRoot directory pointing to the directory containing the file I want to serve. I used the following command:

 ln -s /path/to/file_dir /path/to/doc_root/file_dir 

Then all I had to do was point the xSendFile PHP point to a symbolic link:

 header("X-SendFile: /path/to/doc_root/file_dir/file_name.ext"); 
+2
source

There is an apache / xsendfile configuration value for this.

In the host configuration, you can simply add:

 XSendFilePath /tmp 

Where /tmp is where you want xsendfile to have access. This is a white list, and I think you can add a few.

For instance:

 <Directory /var/www/mysite/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all XSendFile On XSendFilePath /tmp </Directory> 
+2
source

I finally found the simplest solution for this:

 header('X-Sendfile: '.realpath(dirname(__FILE__)).'/'.$the_rest_of_path); 

So it works great for me.

0
source
 header('X-Sendfile: '.$fullPath); 
-3
source

All Articles