Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* PHP current path */
- $path = dirname(__FILE__).'IIS_tmp/games/'; // absolute path to the directory where zipper.php is in
- $filenoext = basename ($filename, '.zip'); // absolute path to the directory where zipper.php is in (lowercase)
- $filenoext = basename ($filenoext, '.ZIP'); // absolute path to the directory where zipper.php is in (when uppercase)
- $generate = rand(00000,99999);
- $targetdir_np = $generate."_".$filenoext; // target directory
- $targetdir = $path . $generate."_".$filenoext;
- $targetzip = $path . $generate."_".$filename; // target zip file
- $targetzip_np = str_replace('.zip', '', "IIS_tmp/games/".$generate."_".$filename); // target zip file
- /* create directory if not exists', otherwise overwrite */
- /* target directory is same as filename without extension */
- if (is_dir($targetdir)) rmdir_recursive ( $targetdir);
- mkdir($targetdir, 0777);
- /* here it is really happening */
- if(move_uploaded_file($source, $targetzip)) {
- $zip = new ZipArchive();
- $x = $zip->open($targetzip); // open the zip file to extract
- if ($x === true) {
- $zip->extractTo($targetdir); // place in the directory with same name
- $zip->close();
- unlink($targetzip);
- }
- $message = "Your .zip file was uploaded and unpacked.";
- } else {
- die(header("location: creategame.php?failed=zip"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement