私は PclZip を使用して zip ファイルを抽出しています。私の問題は、フォルダーが既に存在する場合に、新しいフォルダーを作成して別のフォルダーに zip ファイルを抽出する方法です..
助けてくれてありがとう!
$destination_dir = "/foo/bar";
$new_dir = "/foo/bar2";
if (is_dir($destination_dir)) {mkdir($new_dir); $destination_dir = $new_dir;}
$archive = new PclZip($file);
if ($archive->extract(PCLZIP_OPT_PATH, $destination_dir) == 0) {
die("Unzip failed. Error : ".$archive->errorInfo(true));
}
echo "Successfully extracted files to ".$destination_dir;
$destination_dir = "/foo/bar";
if (file_exists($destination_dir)) { $destination_dir = "/foo/bar2"; }
mkdir($destination_dir);
$archive = new PclZip($file);
if ($archive->extract(PCLZIP_OPT_PATH, $destination_dir) == 0) {
die("Unzip failed. Error : ".$archive->errorInfo(true));
}
echo "Successfully extracted files to ".$destination_dir;