How to Extract/UnZip folder on FTP Server Using PHP

Now days normally we are uploading and downloading work doing on server, but sometimes we need upload a big file on server.There are two option to upload file one is manually unzip the archive on our local computer and upload the extracted folder via FTP and another is create zip file and upload this on FTP. The FTP protocol doesn’t allow the zip file extraction so we need to do it ourselves, here in this quick tutorial i will let you know script which will extract file on FTP.
I am using ZipArchive php class,You can read full documentation and installation from above link.

Also checkout other related tutorials,

There are following steps to need extract zip file on FTP.

Step 1: Create Zip file and upload on FTP.
Step 2: Create a file extract.php.
Step 3: Paste below method on above file.

on above method we need to replace name with your target zip file name and test/ directory with your target directory.In code first we create zip class instance then call open method of zip archive class.If zip is open able then called extract method and finally closed zip.

Step 4:Run extract.php file now you will get all extract file in your target folder.

Leave a Reply

Your email address will not be published. Required fields are marked *