Created
September 12, 2012 14:53
-
-
Save javiertapia/3707164 to your computer and use it in GitHub Desktop.
(PHP5) Extract Zip file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fn = explode('.', $_FILES['archivo']['name']); | |
$ext = array_pop($fn); | |
if($ext == 'zip'){ | |
$files = array(); | |
$zip = new ZipArchive(); | |
if( $zip->open($_FILES['archivo']['tmp_name']) ){ | |
for($i=0; $i<$zip->numFiles; $i++){ | |
$file = $zip->statIndex($i); | |
$files[] = $file['name']; | |
} | |
if(count($files)){ | |
foreach($files as $file){ | |
@unlink($dir . '/' . $file); | |
} | |
$mensaje = count($files) . ' archivo(s) ha(n) sido cargado(s).'; | |
$zip->extractTo($dir); | |
} | |
$zip->close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment