When user tries to download .iso, tar.gz, or .deb from my website php is opening the file instead of downloading it. I'm having a problem with a download script. It runs fine on my local apache server, but when I put it on the my webhost's apache server, it goes crazy. Here's the script:
<?php
$php_scripts = '../../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';
function mydloader($l_filename=NULL){
$ip = GetUserIpAddr();
if (!$pdo = PDOConnect("foxclone_data"))
{ echo "unable to connect";
exit;
}
if( isset( $l_filename ) ) {
header('Content-Type: octet-stream');
header("Content-Disposition: attachment; filename={$l_filename}");
header('Pragma: no-cache');
header('Expires: 0');
readfile($l_filename);
}
else {
echo "isset failed";
}
}
mydloader($_GET["f"]);
exit;
When I say "it goes crazy", I get errors saying that the header values have already been set by apparently by the PDOConnect. Then it actually reads the file. The files being downloaded are .iso, .deb, and .tar.gz. Here's a link to a screenshot: