サイトのリンクからユーザーにダウンロードしてもらいたいワード文書があります。
コードは私の localhost で正常に動作します。しかし、Web サイトをサーバーにアップロードすると、ローカル マシンに保存するオプションが表示されず、ブラウザ自体で開きます。以下は私のコードです:
// 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);
    }
今、私が理解しているように、Content-Disposition を添付ファイルとして指定すると、ファイルを保存するプロンプトが表示されるはずです。
また、.htaccess ファイルに「AddType msword .doc」を追加しました。それでも同じ結果が得られます。
サーバーで行う必要がある追加の設定はありますか?