我有一个文件。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"
use this:
$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);