Category: php


Uzipping Files on Your Web Server

If you are using a free hosting account with and many of the other Free hosts out there, you may have found that they don't offer you a lot of features. One feature that I could not find on free hosting accounts was a utility that would unzip my files after I uploaded them to my server. I had a dating site software that I was trying to install after I uploaded the zip files to my hosting server.

Thus, I wrote a PHP script to unzip my software. This is a quick and dirty hack, does not require a lot of knowledge of how zipfiles work, and the truth is the first example here really has less to do with how to use the php programming language and more to do with how to send system commands to the underlying Linux system using a php script. MAY have added a zipping feature since I wrote this tutorial. Even is so, this information is still useful for any hosting account that may lack a zip file feature. Oftentimes, I have a domain that is for testing purposes, so it really makes financial sense to take advantage of the free hosting accounts that includes with each domain purchase.

Unzipping Files On Linux

My first example is on a Linux//Unix system running an apache server.

Unzipping files on a Linux system is easy. Linux comes with several zipping and unzipping programs that you can call up with the standard input(keyboard).

<?php system('unzip'); ?>

Viola!!! Its that simple. Nothing to it. If your zip File is not corrupted it will deflate with no problems - printing to screen a list of the files that were extracted

The "system()" command is just a way to send commands out to the server's operating system. You can actually use "system()" to run just about any program that can be found on the underlying operating system that is hosting your account if your account has the proper permissions.

Unzipping Files On Windows

Windows does not come with a similar unzip program.

So, we will do a little phping to accomplish this task

<?php $zip = new ZipArchive; if ($zip->open('') === TRUE) { $zip->extractTo('destination/directory/'); $zip->close(); echo 'ok'; } else { echo 'failed'; } ?>

I found the above example in the php manual. I did not see how I could possibly improve on the example, so I left it as is. I do, however, make every attempt to give credit to the correct authors when ever possible. I could have added a lot of fluff and loops to the code but that would only make the script more complicated than necessary. D.Shaun Morgan

Author: D.Shaun Morgan

how to use dreamweaver Dreamweaver - WISIWIG Dreamweaver is a tool that arguably could be called the industry standard for web design . Dreamweaver, is an Adobe product that originally b

how to open create write files php Php file functions, Opening a file in php, reading a file in php, writing a file in php In this tutorial we will look at the most commonly used file functions used in php. The

php example post array php Visual example of how PHP handles the super-global array variable "$_POST" Author: D.Shaun Morgan Versions and Skill Level

how to write php functions php Explanation of a Basic PHP Function What is a PHP function? In PHP a function represents a block of instructions that perform

php passing variables php Pass Variables from One Page to Another -- PHP Author: D.Shaun Morgan Tutorial Outline : Passing PHP variables with $_


Sign Up For


Leave a Comment


Name:      | Email:      | Website:



Enter The Above Security Code: