Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Problem using XSendfile (PHP, Apache,Cpanel)

XSendfile not working, but PHP works just fine

1:18 pm on Jan 9, 2012 (gmt 0)

New User

5+ Year Member

joined:July 14, 2011
posts: 19
votes: 0


I've been banging my head against this quite frustrating little problem for 3 days now and have made almost zero progress. If any one can shed some light on this I would be very grateful.

Our host company has set up and configured XSendfile and we have tested it as working.

We have configured the following in the apache config:

XSendFile on
XSendFilePath /home/beef/shared/

They have applied these settings to all virtual hosts on our server.

If I do a test XSendfile script from


This script immediately serves a file in the shared dir. All good so far.

Now we want to try to run this script from


(julius is a separate cpanel account, but we have a dedicated server and nobody else has access - besides PHP can access cross-account see below).

From this directory, if I do a force-download script:

$file = "/home/beef/shared/pic222.jpg";
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Disposition: attachment; filename="pic222.jpg"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate,post-check=0, pre-check=0');
header("Cache-Control: private",false);
header('Pragma: public');
header('Content-Length: ' . filesize($file));

This works fine and sends the file with no problems. So it does not SEEM to be a permissions issue (though I could be wrong this is not my specialism)

But from the same directory, if I use the same XSendfile script that works in the other directory):

$file = "/home/beef/shared/pic222.jpg";
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"pic222.jpg\"");
header("X-Sendfile: ".$file);

It just sends a 0kb file, and no errors. Have tried a myriad of variations to the XSendfile script, but so far no luck.

Does anyone have any ideas why this may not be working?

Thanks for your help.
1:26 pm on Jan 9, 2012 (gmt 0)

New User

5+ Year Member

joined:July 14, 2011
votes: 0

Please scratch this - apache configuration file was not configured correctly.