我在特定路径中有一个文件.tar.gz。
路径记忆在变量$pathResult
使用此代码我可以下载文件:
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename= " . trim($pathResult));
header("Content-Transfer-Encoding: binary");
readfile(trim($pathResult));
当我获取文件并且我证明要提取内容时,我收到如下错误:no archives identified
为什么???
文件名是:SelectResult1.tar.gz
和$pathResult = "C:/wamp/www/prove/WORKSPACE/8c9d081f/SelectResult1.tar.gz"
答案 0 :(得分:0)
使用它:
$file='/path/file.ext';
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
// read the file from disk
readfile($file);