tags:

views:

44

answers:

2

I tried to unzip a zip file in my server using this code but doesn't work in my server

<?php
     $zip = new ZipArchive;
     $res = $zip->open('Dolphin.zip');
     if ($res === TRUE) {
         $zip->extractTo('dolphin/');
         $zip->close();
         echo 'ok';
     } else {
         echo 'failed';
     }  
?> 

but im getting this

Fatal error: Class 'ZipArchive' not found in **\wwwroot\extractor.php on line 2

HOW TO SOLVE THIS PROBLEM???

+3  A: 

You probably do not have Zip support included in your PHP.

If you are on Linux you need to configure PHP with --with-zip and recompile it.

If you are on Windows, you need to enable php_zip.dll in your php.ini.

You can see more about this at: http://www.php.net/manual/en/zip.installation.php

Alan Geleynse
A: 

Assuming that there actually is a ZipArchive class existing in your class/include path, your code should be:

$zip = new ZipArchive();

If the class doesn't actually exist (ie: you need to install a library...) then that's a completely different problem.

Brian Driscoll
The syntax is correct, you don't need the brackets.
Daff
Not related to problem. The `()` is optional if the constructor doesn't require any arguments...
ircmaxell
I learn something new every day! :)
Brian Driscoll