我想允许用户从服务器上下载特定文件,并让他们选择文件的名称。PHP“另存为...”文件
这是一个JSON文件。
我有以下的PHP脚本的作品,但它会自动命名文件:
if (file_exists($myFile)){
header ("Content-Type: application/download");
header ("Content-Disposition: attachment; filename=$myFile");
header("Content-Length: " . filesize("$myFile"));
$fp = fopen("$myFile", "r");
fpassthru($fp);
} else {
echo "no file exists";
};
它完全取决于浏览器给用户一个名称的选择或用“默认”名称保存它。你无法对此做任何事情。 – deceze