📜  PHP 将文件解压缩到目录中,更改解压缩文件夹的名称 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:15.550000             🧑  作者: Mango

代码示例1
$zipFile = "test.zip";
$fnNoExt = basename($zipFile, ".zip");
$date = new DateTime();
$now = $date->getTimestamp();
$destinationFolder = "/some/path/$fnNoExt-$now";

$zip = new ZipArchive;
if ($zip->open($zipFile, ZipArchive::CREATE) === TRUE) {
    if(!is_dir($destinationFolder)){
        mkdir($destinationFolder,  0777);
    }
    $zip->extractTo($destinationFolder);
    $zip->close();
} else {
    return FALSE;
}