Advertisement
wehandler

Unzipers extract zip files v0.5

Nov 22nd, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2. $path_zip = "dnamusic.zip";
  3. $tmp_folder = "dnamusic/";
  4.     $all_files = array();
  5.  
  6.     $zip = zip_open($path_zip);
  7.     if ($zip) {
  8.         $stream = zip_read($zip);
  9.         while ($stream) {
  10.             var_dump($zip_name);
  11.             $zip_name = zip_entry_name($stream);
  12.  
  13.             $path_file_unzip = $tmp_folder.$zip_name;
  14.             $dir_folder = substr($path_file_unzip, 0, strrpos($path_file_unzip, "/"));
  15.             print_r($path_file_unzip);
  16. if (!file_exists($dir_folder)){ mkdir($dir_folder,0777,true);
  17. }
  18.  
  19. if (!file_exists($path_file_unzip)){
  20. $fp = fopen($path_file_unzip, "w");
  21. echo("$path_file_unzip is a regular file");
  22.             array_push($all_files, $path_file_unzip);
  23.            
  24.             if(zip_entry_open($zip, $stream, "r")) {
  25. $buf = zip_entry_read($stream, zip_entry_filesize($stream));
  26.                 fwrite($fp, "$buf");
  27.                 zip_entry_close($stream);
  28.                 fclose($fp);
  29.             }
  30. }
  31.            
  32.             $stream = zip_read($zip);
  33.         }
  34.  
  35.         zip_close($zip);
  36.     }
  37.  
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement