Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite during extraction? #18

Open
patjk opened this issue Jun 1, 2020 · 1 comment
Open

Overwrite during extraction? #18

patjk opened this issue Jun 1, 2020 · 1 comment

Comments

@patjk
Copy link

patjk commented Jun 1, 2020

It doesn't appear to overwrite existing files when extracting, nor have an option to. Would be a nice added feature to have.

Cheers

@wilhelmer
Copy link

I had the same problem. It seems overwriting isn't working properly using ZipArchive::extractTo.

Instead, you can use PharData::extractTo, where you can explicitly enable overwriting.

public static function extractZipArchive($archive, $destination) {
    try {
      $phar = new PharData($archive);
      if ($phar->extractTo($destination, null, true)) {
        $GLOBALS['status'] = array('success' => 'Extracted archive successfully.');
      }
      else {
        $GLOBALS['status'] = array('error' => 'Error while extracting.');
      }        
    }
    catch (Exception $e) {
      $GLOBALS['status'] = array('error' => $e->getMessage());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants