Jump to content

Server settings to enable force download ...


ou812

Recommended Posts

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:

 

<?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*);
    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

Perhaps it's just a side effect of posting it on here, but it's not a valid script (which the highlighting clearly shows). I'd recommend looking into readfile, I'm not sure if it will solve your problem or not, but it would certainly seem easier.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.