Php Code To Unzip Files

Forum 9 years ago

Php Code To Unzip Files

Few Days Ago some New-In Webmasters Who In One Way Or The other Want to Start Up their Hosting Websites From A Free Hosting, have been Having Problems Trying to Extract Files In the Zip They Have Uploaded, With The Continual Quest of Alternative FTP server, Not Knowing PHP can virtually do Everything for Us.

With All Complains Led, I bring You, PHP: UNZIP SNIPPET a Recode By Sunnex, to Enable you Understand The Full Functionality.

HOW TO USE THIS SHORT CODE TO UNZIP A ZIP ARCHIVE

[quote2]
1. Create a New Php File e.g unzip.php

2. Copy And Paste Below Codes Into The file

[ads4]


//Php Unzip Code Snippet
// @@Editor: SunnEx Fidelis (Waploaded.com)
// For Unziping ZIp Archive Easily

$zip = new ZipArchive; //Php Function to Detect Zip archive
$zipname = 'theziptoextract.zip'; //Change theziptoextract.zip to The Zip file Name You want To Extract
if($zip->open($zipname))
{
for($i=0; $i<$zip->numFiles; $i++)
{
echo 'Filename: '.$zip->getNameIndex($i).'
';
}

if($zip->extractTo(dirname(__FILE__).'')) //The Line shows The file Would Be extracted To same Folder The code Was Created
{ echo '

FILE EXTRACTED

'; }

else{ echo '

ERROR IN FILE ECTRACTING!

';
}

$zip->close();
}
else
{
echo 'Error reading zip-archive!';
}
?>

3. Make sue to Change theziptoextract.zip To The Zip file Name You Want to Extract

4. Now save The File

5. Then Visit for Example Yoursite.com/unzip.php from Your Web Browser

NOTE: You Must Visit The Exact Path Where The Unzip.php is Located in Your site
[/quote2]

With That, You are Done as It will Take Few Minutes or seconds to Do The Extraction

WARNING: For security Reasons, Always Delete unzip.php From Your server after Use, Or rename to What People Cant Think of, Or Better Still CHMOD it to No User Access.

NOTE: To Save you stress Of The Inability of Compress & Extract In free Hosting, You can Purchase a Cheap Hosting for as Low a #300 Or Lower Per Month At Hostmeout.com Enjoi...

if You are Not still Cleared, or Get any Error, Please Lay complains below, and NOTE, this snippet Has already been tested By us, so Settle down while giving Your Trial

What's your rating?
0
{{ratingsCount}} Votes


Related forums
Money Laundering: Kano Anti-Graft Commission Files Fresh Charges Against Ganduje
Forum | 1 week ago

Money Laundering: Kano Anti-Graft Commission Files Fresh Charges Against Ganduje

Wigwe: Ogunbanjo’s Family Files Lawsuit Against Charter Company Over Helicopter Crash
Forum | 1 week ago

Wigwe: Ogunbanjo’s Family Files Lawsuit Against Charter Company Over Helicopter Crash

EFCC Files Fresh 26-Count Charge Against Emefiele
Forum | 2 weeks ago

EFCC Files Fresh 26-Count Charge Against Emefiele

APC Chairman Ganduje Reacts As Kano Government Files 8-Count Charge Against Him For ‘Receiving $200k’ From Contractor
Forum | 2 weeks ago

APC Chairman Ganduje Reacts As Kano Government Files 8-Count Charge Against Him For ‘Receiving $200k’ From Contractor