Hi,
I can force a download file with this code and it works.
I know what the switch statement does but I am unsure about the rest.
Is all this code needed for a forced download?
$file_extension = strtolower(substr(strrchr($file,”.”),1));
if ((isset($file))&&(file_exists($file)))
{
switch( $file_extension )
{
case “pdf”: $ctype=”application/pdf”; break;
case “exe”: $ctype=”application/octet-stream”; break;
…
}
header(“Pragma: public”); // required
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: private”,false); // required for certain browsers
header(“Content-type: application/force-download”);
header(‘Content-Disposition: inline; filename=”‘ .$file . ‘”‘);
header(“Content-Transfer-Encoding: Binary”);
header(“Content-length: “.filesize($file));
header(“Content-Type: $ctype”);
header(‘Content-Disposition: attachment; filename=”‘ . $file . ‘”‘);
readfile(“$file”);