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

প্রাকৃতিক সম্পদ ব্যৱস্থাপনা

  1. বৃহৎ নদীবান্ধ নিৰ্মাণৰ লগত জড়িত হৈ থকা সমস্যাসমূহ হ’ল— (a) বৃহৎ পৰিমাণৰ শস্য পথাৰ হেৰুৱালগীয়া হয় (b) বৃহৎ পৰিস্থিতিতন্ত্র বিনষ্ট হয...