Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to unzip a file uisng PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 113
    Comment on it

    Hello Reader's!, If you have a zip file and you need to execute unzip the file using PHP, Then you can use the PHP liberary code below:-

    // Lets say you have zip file in the same folder of php file.
    $file = 'file.zip';
    
    // get the absolute path to $file
    $path = pathinfo(realpath($file), PATHINFO_DIRNAME);
    
    $zip = new ZipArchive;
    $res = $zip->open($file);
    if ($res === TRUE) {
      // extract it to the path we determined above
      $zip->extractTo($path);
      $zip->close();
      echo "Your file is now unziped! $file extracted to $path";
    } else {
      echo "Error! fail to open file: $file";
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: