xsendfile sends a blank file

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 3
Joined: 04 Jun 2014, 06:33

xsendfile sends a blank file

04 Jun 2014, 06:41

I recently installed the xsendfile mod on my WAMP and had a similar issue until I added this to my htaccess:

Code: Select all
<IfModule mod_xsendfile.c>
  XSendFile on
</IfModule>

Now I've downloaded Helicon Ape to run the same module on my IIS.

I have a simple .php script and a small .txt file for testing.

My php is as follows:

Code: Select all
<?php
//We want to force a download box with the filename hello.txt
header('Content-Disposition: attachment;filename=testfile.txt');
header("Content-Type: application/force-download");
//File is located at /home/username/hello.txt
header('X-Sendfile: /inetpub/wwwroot/xsendfile/testfile.txt');


When I click on my xsendfile.php in my xsendfile directory, it brings up a windows browse box, I hit ok to download, and a testfile.txt IS downloaded. However it is always blank.

I added this to my httpd.conf in Helicon Ape Manager:

Code: Select all
XSendFilePath c:/inetpub/wwwroot/xsendfile


And then clicked on my default website in Helicon Ape Manager and added this to my .htaccess:

Code: Select all
<IfModule mod_xsendfile.c>
  XSendFile on
</IfModule>


But I am still getting a blank file and not my correct .txt file. I have tried several relative directories etc to my code however, the following works perfectly on my WAMP:

Code: Select all
header('X-Sendfile: /wamp/zxy/xsendfile/testfile.txt');


Any help would be greatly appreciated.

Aravona

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: xsendfile sends a blank file

04 Jun 2014, 07:06

Hello, Aravona

Here are some suggestions:

- leave just

XSendFile on

instead of

<IfModule mod_xsendfile.c>
XSendFile on
</IfModule>

in .htaccess

- try to use Content-type known to IIS, for example

text/plain

- in the following line specify absolute path starting with C://...

header('X-Sendfile: /inetpub/wwwroot/xsendfile/testfile.txt');

- try to download the file directly as http://localhost/xsendfile/testfile.txt. Will it download fine?

User avatar
Posts: 3
Joined: 04 Jun 2014, 06:33

Re: xsendfile sends a blank file

04 Jun 2014, 07:13

If I just leave 'XSendFile on' then it says 'page cannot load' and the file does not run, it only runs inside the ifmodule.

I have tried 'header('X-Sendfile: C:/inetpub/wwwroot/xsendfile/testfile.txt');' and 'header('X-Sendfile: C://inetpub/wwwroot/xsendfile/testfile.txt');' to no avail.

Also 'header("Content-Type: text/plain");' did not work either, still a blank file.

I can display my file from: http://localhost:81/xsendfile/testfile.txt (my IIS localhost) OR http://localhost/xsendfile/testfile.txt (my WAMP localhost) in my browser perfectly fine.

User avatar
Posts: 3
Joined: 04 Jun 2014, 06:33

Re: xsendfile sends a blank file

04 Jun 2014, 07:28

Fixed it. Seemed to have been an issue with my fastcgi.

Incase anyone else has this issue try:

Code: Select all
<Location /php-fcgi/php-cgi.exe>
  Options +ExecCGI
  SetHandler fastcgi-script
  XSendFile On
</Location>


in your htaccess.

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 2 guests