Jump to content

Zip-ExtractTo Help Please.


Cnielsen4211

Recommended Posts

Just when I finally figured out how to create a Zip file and I thought the rest would be easy… This problem comes along…

 

When I attempt to extract files from a Zip with the following code;

 

$uzipfolder = 'tempdir';

$filename = 'MyZipTest.zip';

$zipfolder = 'tempdir/';

 

        $zip = new ZipArchive;

$zipfile = $zipfolder.$filename;

 

echo 'Zip file is '.$zipfile.'<br>';  //correct

echo 'The unZip folder is '.$uzipfolder.'<br>'; // correct

 

chmod($uzipfolder,0777); // the folder has permissions 0777

$res = $zip->open($zipfile);

        if ($res === TRUE) {    

        $zip->extractTo($uzipfolder);

$zip->close();

//unlink($zipfile); // I removed this line to preserve my zip file       

        echo 'Ok<br>';

    } else {

        echo 'failed<br>';

    }

 

The Extracted files are created and in the correct “tempdir” folder, but I get  error messages saying “Warning: ZipArchive::extractTo(tempdir/..) [ziparchive.extractto]: failed to open stream: Is a directory”

 

The files are extracted and are in the tempdir directory so if it wasn’t for the error message all would be ok.

 

If I change the line “$zip->extractTo($uzipfolder);” to $zip->extractTo($uzipfolder,””); as it should be I don’t get any error message, and I don’t get any extracted files…

 

Can someone tell me what I’m doing wrong, please… :confused:

 

Kind Regards

CNielsen4211

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.