1

私は PclZip を使用して zip ファイルを抽出しています。私の問題は、フォルダーが既に存在する場合に、新しいフォルダーを作成して別のフォルダーに zip ファイルを抽出する方法です..

助けてくれてありがとう!

4

2 に答える 2

1
    $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;
于 2011-08-05T14:11:37.600 に答える
0
    $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;
于 2011-08-05T14:22:22.237 に答える