Skip to main content

Posts

Showing posts from May, 2020

Unzip Zip file from PHP code Extract the Zip file with PHP

You don’t need to require any other extra plugin for working with Zip files. // Get Project path define('_PATH', dirname(__FILE__)); // Zip file name $filename = 'zipfile.zip'; $zip = new ZipArchive; $res = $zip->open($filename); if ($res === TRUE) { // Unzip path $path = _PATH."/files/"; // Extract file $zip->extractTo($path); $zip->close(); echo 'Unzip!'; } else { echo 'failed!'; }