I'm running 2 simple function:
<?php
$zipUrl = "path_of_original.zip"
$zipFilename = "local_path_and_name_of.zip"
$unzipPath = "destination_of_unzipped_files"
upload_archive ($zipUrl, $zipFilename);
unzip_archive ($zipFilename, $unzipPath);
?>
the 1st, upload a .zip archive on server
function upload_archive ($zipUrl, $zipFilename){
define('BUFSIZ', 4095);
$rfile = fopen($zipUrl, 'r');
$lfile = fopen($zipFilename, 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);}
the 2nd, unzip the archive
function unzip_archive ($zipFilename, $unzipPath){
$zip = new ZipArchive;
$res = $zip->open($zipFilename);
if ($res === TRUE) {
$zip->extractTo($unzipPath);
$zip->close();
echo 'success!';
} else {
echo 'error!';
}
}
when these 2 functions are executed separately everything's fine, but when executed in sequence I can't appreciate the output of the second function (unzip).
I think the problem is that the .zip file is still locked in write by the first function.
any Suggestions?
Angelo.