Jump to content

Class 'ZipArchive' not found


kristo5747

Recommended Posts

Hello,

 

I am trying to implement a simple script that ZIPs up a text file.

 

The problem is that I don't think the ZIPArchive is available on my server. Here is an example of my code:

 

<?php
$zip = new ZipArchive();
$filename = "./PJR.v2.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
    exit("cannot open <$filename>\n");
}
if ($handle = opendir('WORKDIR')) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != "..") {
        $zip->addFile($entry);
        }
    }
  closedir($handle);
}
$zip->close();
?>

 

When I run it from the command line, I get

PHP Fatal error:  Class 'ZipArchive' not found in /users/albert/zip_POC.v2.php on line 2

 

This is the version info on my server:

 

php -v
PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:53)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

 

Is there a way that I can install that class even though I am not the 'root' user??

Link to comment
Share on other sites

Is Your server on Windows, linux or some other OS?

 

Linux Red Hat (Sorry I forgot to mention that).

 

Further investigating shows PHP was not compiled on my server with ZIP support. The configure command section of PhpInfo() does not show the --enable-zip option. PECL is not installed either so I cannot workaround my problem with pecl install zip either.

 

I am not sure what to do next.... :confused:

 

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.