I have a word document which I want the users to download from a link on site .
The code works fine on my localhost . However , when I upload the website on the server , instead of giving the option to save on the local machine , it opens up in the browser itself . Below is my code :
// Define the path to file
$file = <filepath>;
if(!file_exists($file))
{
die('Hard Copy does not exist on Server at the moment . Sorry for the inconvinience');
}
else
{
// required for IE, otherwise Content-Disposition may be ignored
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
ob_clean();
// Set headers
header("Cache-Control: private");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/msword");
header("Content-Transfer-Encoding: binary");
readfile($file);
}
Now , as I understand that , if I give Content-Disposition as attachment , it should give a prompt to save the file .
Also , I have added " AddType msword .doc " in my .htaccess file . Still it gives the same result .
Is there any additional setting which needs to be done on the server ?