Easier way to upload so many files to a host

If you’ve so many files to upload in a server, its better to create a compressed (zip or tar) file containing those files and upload it using your favorite ftp client. Later extract them either using control panel or using ssh (you can use putty from windows). But in many server, you might don’t have any tool to extract that compressed file or you might not have ssh panel. I was in such situation this morning, so I decided to create a php file there(on host) with following codes which does this job(extract files from zipped version)

<?php
$zip = new ZipArchive;
if ($zip->open('MYFILES.zip') === TRUE) {
$zip->extractTo('./');
$zip->close();
echo 'Extraction successful';
} else {
echo 'failed';
}
?>

You’ve to change the filename on line 2 as your own, then hit this file in your browser which will tell you if it able to extract it or not.

It worked for me. It is just simple piece of codes available online but I couldn’t resist myself to share it as this might help other.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s