Hi,
I´m having problems to unzip a file, I tried 2 routine, but I have no success. Could anybody help me? The routine unzip some files, but the one that I want no.
The routines:
[CODE]$zip = new ZipArchive;
if ($zip->open($nome_file) === TRUE) {
$zip->extractTo(“./upload”);
$zip->close();
echo “ok”;
} else {
echo “failed”;
}
OR
[CODE]$zip = zip_open($nome_file);
if($zip){
while ($zip_entry = zip_read($zip)) {
zip_entry_open($zip, $zip_entry);
if (substr(zip_entry_name($zip_entry), -1) == ‘/’) {
$zdir = substr(zip_entry_name($zip_entry), 0, -1);
if (file_exists($zdir)) {
trigger_error(‘Directory “<b>’ . $zdir . ‘</b>” exists’, E_USER_ERROR);
return false;
}
mkdir($zdir);
}
else {
$name = zip_entry_name($zip_entry);
chdir(‘upload’);
if (file_exists($name)) {
trigger_error(‘File “<b>’ . $name . ‘</b>” exists’, E_USER_ERROR);
return false;
}
$fopen = fopen($name, “w”);
fwrite($fopen, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)), zip_entry_filesize($zip_entry));
}
zip_entry_close($zip_entry);
}
zip_close($zip);
return true;
}
else{
echo “Faliled to open”;
}
Note: When I unzip using some program like Winrar and compress again with this program, the file is unziped. And I tried to use this site: [url]http://www.wobzip.org/index.php
Thank you,