2010-11-23 52 views
1

我使用move_upload_file功能將文件移動到我的文件夾中移動文件時,它的做工精細,但我想zip壓縮format.plz任何機構幫助...如何對ZIP壓縮格式

回答

0

看看在zip擴展:

http://www.php.net/manual/en/zip.examples.php

我看着你鏈接到的代碼,並進行了一些更改(如果你在問題中包含它,它會一直好):

$nameFile = $_FILES['file']['name']; 
$tmpName = $_FILES['file']['tmp_name']; 
$download_folder = './files/'; 

$zip = new ZipArchive(); 
$fileconpress = $download_folder.$nameFile.".zip"; 

$conpress = $zip->open($fileconpress, ZIPARCHIVE::CREATE); 
if ($conpress === true) 
{ 
    $zip->addFile($tmpName); 
    $zip->close(); 
    echo $fileconpress."<br/>"; 
    echo "yess !! Success!!!! "; 
} 
else echo " Oh No! Error"; 

重要的部分,可能是什麼導致你的錯誤是$ download_folder。您需要定義要保存文件的路徑。

我也去掉了fread(),您可以將文件只加載直入拉鍊的對象與addFile()