Advertisement
Guest User

Untitled

a guest
May 25th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /* PHP current path */
  2. $path = dirname(__FILE__).'IIS_tmp/games/'; // absolute path to the directory where zipper.php is in
  3. $filenoext = basename ($filename, '.zip'); // absolute path to the directory where zipper.php is in (lowercase)
  4. $filenoext = basename ($filenoext, '.ZIP'); // absolute path to the directory where zipper.php is in (when uppercase)
  5.  
  6. $generate = rand(00000,99999);
  7.  
  8. $targetdir_np = $generate."_".$filenoext; // target directory
  9. $targetdir = $path . $generate."_".$filenoext;
  10. $targetzip = $path . $generate."_".$filename; // target zip file
  11. $targetzip_np = str_replace('.zip', '', "IIS_tmp/games/".$generate."_".$filename); // target zip file
  12.  
  13. /* create directory if not exists', otherwise overwrite */
  14. /* target directory is same as filename without extension */
  15.  
  16. if (is_dir($targetdir)) rmdir_recursive ( $targetdir);
  17.  
  18.  
  19. mkdir($targetdir, 0777);
  20.  
  21.  
  22. /* here it is really happening */
  23.  
  24. if(move_uploaded_file($source, $targetzip)) {
  25.  
  26. $zip = new ZipArchive();
  27. $x = $zip->open($targetzip); // open the zip file to extract
  28. if ($x === true) {
  29. $zip->extractTo($targetdir); // place in the directory with same name
  30. $zip->close();
  31.  
  32. unlink($targetzip);
  33. }
  34. $message = "Your .zip file was uploaded and unpacked.";
  35. } else {
  36. die(header("location: creategame.php?failed=zip"));
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement