Unzip

From: Date: Wed, 08 Jul 2009 11:44:35 +0000
Subject: Unzip
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-5274@lists.php.net to get a copy of this message
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: $zip = new ZipArchive; if ($zip->open($nome_file) === TRUE) { $zip->extractTo("./upload"); $zip->close(); echo "ok"; } else { echo "failed"; } *OR* $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 "Falha ao abrir"; } 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: http://www.wobzip.org/index.php , at this site, my file is uncompress perfectly, so there is a way, but I don't know how! Thank you, -- Cláudia Satie Fujiwara

« previous php.webmaster (#5274) next »