Search code examples
phpfileunzip

Can't unzip file with php


I have a folder in my web server were I put zip files that I need to then unzip. I want to do that with php and this is what I have tried but it does not work:

<?php
$file = $_GET["file"];
$zip = new ZipArchive;
$res = $zip->open($file+'.zip');
$zip->extractTo('./');
$zip->close();
?>

The zip files are in the same folder as the php file, but when I go to the php page it does nothing.

By doing some testing I have found out that the script dies on the $zip = new ZipArchive; line

How can I manage this to work?


Solution

  • I have found the problem. The code is fine, but the hosting service is not, and they do not have the ZIP extension available right now