NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home / News / Webmaster / Tips and Tricks

Tips and Tricks


A Simple PHP Script to Create ZIP Archives on Windows

ZIP Files Management in PHP 5.2.0

By Catalin Bocanu, Web News Editor

13th of March 2008, 16:47 GMT

Adjust text size:


ZIP Archive Icon
Enlarge picture
The ZIP archives are very popular and extensively used for data compression. For commonly used operating systems like Windows, Linux and MacOS, there are many utilities
that help you to manage ZIP archives, like 7-zip for example. When you need to manage ZIP files with the help of PHP web applications running on server side, multiple alternatives exist.

The ZIP archives manipulation can be performed by using various classes or the PHP ZIP extension, which enables you to handle the creation of archives having ZIP compression type. On Linux operating systems, the PHP must be compiled with support for ZIP archives and on Windows operating systems the extension php_zip.dll must be enabled by editing the corresponding line in the php.ini file.

In order to simplify the task of PHP configuration to enable support for ZIP archives management on Windows operating system, WAMP application allows you to install the PHP ZIP extension in a visual manner by checking the corresponding entry in the PHP extensions menu.

For other LAMP distributions for Windows, having PHP version 5.2.0 or higher, the PHP ZIP extension must be enabled by uncommenting the line #extension=php_zip.dll (delete # character) in the php.ini configuration file. Then the php.ini file must be saved and the Apache server restarted in order to reflect the new changes in the PHP configuration.

By using certain PHP scripts, you will be able to extract or add files to a newly created or existing ZIP archive, list archive contents and more. For example, by using the next PHP, script various files can be added to a new ZIP archive:

CODE

If you want to test this script, copy and paste it into a text file that must be saved with .php extension. It will create a ZIP archive called test.zip containing two files ex1.doc and ex2.doc, if they are in the same directory with test.php script. The new ZIP archive object is created in the third line of the script.

The lines 6 and 7 can be multiplied corresponding to the number of files you want to be in the ZIP archive. You can add your own documents or files in an archive by specifying their complete name in the argument of addFile directive. The archive name can also be changed in line 2. Supplementary operations can also be performed over the ZIP archive by using various others functions. The complete description of functions related to ZIP files management in PHP can be found here.

TAGS:

PHP Functions | ZIP Archives | PHP ZIP Extension | Archives in PHP | ZIP Utility
Read by 9,608 user(s) | Add comment | Link to this article TWEET THIS


Article rating:
Good (3.0/5) 14 vote(s)    

Subscribe to news | Print article | Send to friend

© Copyright 2001-2009 Softpedia
Contact:

 

 

SEARCH THE NEWS ARCHIVE :




Today's News
| Yesterday's News | News Archive


MORE RELATED ARTICLES:


Free CMS Suitable For A Low Disk Space

Shopping Cart Management Without Programming

Efficient Backup of MySQL Databases

Get A Free Computer and Network Data Tracker

Get a Simple Blog Application for Beginners

Freeway

Security of Free Content Management Systems

A Content Management System for Everyone

A Few Guidelines to Build A New Website

HTML Purifier

User opinions:

No user comments yet.
Be the first to express your opinion using the form below!

Share your opinion:

Your Name:
Your Email Address:
(will not be used for commercial purposes)
Solve this to prove you're not a bot: =
Your review/opinion:

 




Windows tabGames tabDrivers tabMac tabLinux tabScripts tabMobile tabHandheld tabGadgets tabNews tab

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   ENTER NEWS SITE   |   ENGLISH BOARD   |   ROMANIAN FORUM