Server settings to enable force download ...

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
ccannon
Forum Newbie
Posts: 1
Joined: Sat Dec 12, 2009 2:09 pm

Server settings to enable force download ...

Post by ccannon »

i'm hoping someone can point me to a server setting that needs to be changed in php.ini or httpd.conf (or some other place?) to solve a force download script problem i have with on a new server.

i have a force download script that runs fine on the old server (and other servers i've used it on) with both Internet Explorer and other browsers, working example here:

http://weightloss123.com/test/test.html

both the 400K and 30K files download as expected in IE and other browsers, but on the new server ...

http://www.foreclosureforcash.com/test/test.html

in Internet Explorer, only the 30K file will download and the 400K download fails.

my assumption is the script is good because it works on the old server and a number of other servers i've used it on in both IE and other browsers.

for reference, here's an example of the working script:

Code: Select all

<?php
session_start();
 
$download_dir = "/server/path/to/download/dir";
$file_path = $download_dir . DIRECTORY_SEPARATOR . $_GET['file'];
 
$asfname = $_GET['file'];
$fsize = filesize($file_path);
$mtype = "application/force-download";
header("Pragma: public");
pre-check=0");
header("Expires: -1");
header("Cache-Control: no-cache");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $mtype");
header("Content-Disposition: attachment; filename=\"$asfname\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
 
$file = @fopen($file_path,"rb");
if ($file) {
  while(!feof($file)) {
    print(fread($file, 1024*8));
    flush();
    if (connection_status()!=0) {
      @fclose($file);
      die();
    }
  }
  @fclose($file);
}
 
?>
let me know if you can point me to a specific change or changes i might make to the setup of the new server to solve this problem.

Thanks for your help ...

-Chris
Post Reply