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!");  

1 Answer 1


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.

  • 1
    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
    Commented Jan 29, 2011 at 10:40
  • Interesting. How do the wordpress installer routines get around this? I would want to do similar.
    – Scott B
    Commented Jan 29, 2011 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
    Commented Jan 30, 2011 at 9:29
  • I agree, I've added it as a separate question > wordpress.stackexchange.com/questions/8213/…
    – Scott B
    Commented Jan 31, 2011 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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