0

file.magicExt単なるテキストファイル (utf-8) のファイルがあります。例:

hello

私は持っていますindex.php

<?php

echo '<a href="file.magicExt">file</a>';

私が望むのは、ユーザーが「ファイル」リンクをクリックしたときに「開く」ダイアログを表示することです。

代わりに、ブラウザ (Firefox、Chrome) にファイルの内容が表示されます。

4

1 に答える 1

0

私はそのようなものでそれをやり遂げましたfile.php:

<?php

// We'll be outputting a .magicExt
header('Content-Type: application/magicExt');

// It will be called downloaded.magicExt
header('Content-Disposition: attachment; filename="downloaded.magicExt"');

// The .magicExt source is in original.magicExt
readfile('original.magicExt');

PHP header() 関数に基づく

そしてそれindex.php

echo '<a href="file.php">file</a>';
于 2015-03-07T01:57:25.477 に答える