WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What would cause this error:

Fatal error: Class 'ZipArchive' not found in /home/test/dummyurl.com/wp-content/themes/mytheme/upload-zip.php on line 14

PHP Version is 5.3.1

Does WP have a built in function I should use instead? Like perhaps the "unzip_file" function line 525 of ./wp-admin/includes/file.php"?

function openZip($file_to_open) { 
    global $target;  
    $zip = new ZipArchive();  //This is line 14
    $x = $zip->open($file_to_open);  
    if($x === true) {  
    } else {  
        die("There was a problem. Please try again!");  
share|improve this question
up vote 2 down vote accepted

It means your PHP installation doesn't have the Zip library. You can install it by recompiling PHP with the --enable-zip option, or install the PECL package.

share|improve this answer
if you are on shared hosting I would recommend writing to your host to see if they can enable it for your site. They may have it disabled as zipping can be a CPU intensive operation. – Bala Clark Jan 29 '11 at 10:40
Interesting. How do the wordpress installer routines get around this? I would want to do similar. – Scott B Jan 29 '11 at 14:09
@Scott B: There is a function unzip_file() which first tries ZipArchive like you do, but if it does not exist it falls back on PclZip, an zip library written in PHP. So I suggest you try to use this function unzip_file() too, as it will probably always exist in WordPress. (Maybe we should rewrite this question so it becomes "How to unzip files without ZipArchive?") – Jan Fabry Jan 30 '11 at 9:29
I agree, I've added it as a separate question > wordpress.stackexchange.com/questions/8213/… – Scott B Jan 31 '11 at 17:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.