作者ntouckcm (知足常樂)
看板PHP
標題[請益] 壓縮檔
時間Sun Jan 27 16:13:54 2008
請問一下
我要把檔案打包變成壓縮檔下載
$file = "D:\\www\\"; //檔案路徑
system("tar -zpcf hw1.tgz view_car.c view.c",$output);
//把view_car.c view.c變成壓縮檔
if(!$output=false){
header('Content-Description: File Transfer');
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=hw1.tgz");
readfile($file);
}
是可以下載但是壓縮檔裡是空的,沒有檔案。
請問有人知道為什麼會這樣嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.160.61.127
推 aqzb:因為$file還是資料夾?readfile($file.'hw1.tgz');呢 01/27 16:56
→ ntouckcm:還是不行耶,因為$file路徑裡沒有hw1.tgz這個檔 01/27 17:08
→ ntouckcm:壓縮完的檔好像沒有存在電腦裡耶..... 01/27 17:12
→ ntouckcm:這樣是沒有成功壓縮嗎? 01/27 17:13
推 aqzb:but 你windows下有tar這程式嗎.. 01/27 23:44