homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Problem using XSendfile (PHP, Apache,Cpanel)
XSendfile not working, but PHP works just fine

Msg#: 4405187 posted 1:18 pm on Jan 9, 2012 (gmt 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.



Msg#: 4405187 posted 1:26 pm on Jan 9, 2012 (gmt 0)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved