I found this script somewhere on the net, basically it forces a file to be downloaded instead of viewed inside of the web browser, by making it an attachment in the header. The code is:
if( $filename == "" )
{
echo "ERROR: download file NOT SPECIFIED. Please Contact the Staff to Notify them of this Error.";
exit;
} elseif ( ! file_exists( $filename ) )
{
echo "ERROR: File not found. Please Contact the Staff to Notify them of this Error.";
exit;
};
header("HTTP/1.1 200 OK");
header("Content-Length: ".filesize($filename));
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
header("Content-Transfer-Encoding: binary");
readfile($filename);
}
?>
The problem is, while this works and does cause them to download the file, the download stops half way for many people, so incomplete files are downloaded. This only happens for some people, I dont actually have this problem, when I try everything downloads correctly.
Anyone have an idea what might be causing this problem?