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
https://forums.phpfreaks.com/topic/216523-zip-extractto-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.