我正在尝试从目标server
下载文件,收到文件后,我想打开一个对话框,让我选择保存位置。
到目前为止,我仅用于简单下载:
<a class="button" type="application/octet-stream" href="http://localhost:5300/get" download>Click here for dld</a>
我已阅读到我需要使用FileApi
来实现此目的,但是仍然不能在所有浏览器中使用。
我如何设法打开对话框?
答案 0 :(得分:1)
只需使用
<?php
ob_end_clean();
$filePath = 'P:\niks\all Zip Files\Reports\Report 01 feb 2019.zip';
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=\"" . basename($filePath) . "\";");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
答案 1 :(得分:1)
尝试使用有助于处理下载操作的jquery.fileDownload.js