js

Thursday, February 29, 2024

PHP: write a php code to unzip `.zip` file

 Q. Write a php code to unzip `.zip` file

Solution:
<?php

// Specify the path to the zip file
$zipFilePath = 'path/to/sample.zip';

// Specify the directory where you want to extract the contents
$extractPath = 'path/to/output/folder/';

// Create a ZipArchive object
$zip = new ZipArchive;

// Open the zip file
if ($zip->open($zipFilePath) === TRUE) {
    
    // Extract the contents to the specified directory
    $zip->extractTo($extractPath);
    
    // Close the zip file
    $zip->close();
    
    echo 'Extraction successful!';
} else {
    echo 'Failed to open the zip file';
}
?>

No comments:

Post a Comment

SEBA Class X Science অধ্যায়-১৬ প্রাকৃতিক সম্পদৰ ব্যৱস্থাপনা Questions and Answers

  অধ্যায়-১৬ প্রাকৃতিক সম্পদৰ ব্যৱস্থাপনা নির্বাচিত প্রশ্নোত্তৰ প্রশ্নঃ বৃহৎ নদীবান্ধ নিৰ্মাণৰ লগত জড়িত থকা সমস্যা এটা উল্লেখ কৰা। HSL...