I have a tutorial from a website Net Tuts which is used to upload a zip file and extract the data from within the file into the server.
Copying and pasting the code straight from the web page did not work, an error occured half way through the script being processed.
Fatal error: Cannot instantiate non-existent class: ziparchive in /www/website_here.co.uk/httpdocs/test/functions.php on line 6
Is it possible that this is to do with the version of PHP I am using? Here is the code it gets stuck on:
<?php function openZip($file_to_open) { global $target; global $unique_folder; $zip = new ZipArchive(); $x = $zip->open($file_to_open); if ($x === true) { $zip->extractTo($target . $unique_folder); $zip->close(); unlink($file_to_open); #deletes the zip file. We no longer need it. } else { die('There was a problem. Please try again!'); } } ?>
line 6: $zip = new ZipArchive();
I am using PHP version 4.3.9.
On PHP 4 you absolutely need to install PECL zip 1.1.0 (or newer) in order to have access to the
ZipArchiveclass. Follow these instructions.If that is not possible, you will have to use the non-OO
zip_open,zip_readetc. API.