Search Perform an advanced search query SOFTPEDIA
 
SOFTPEDIA
Updated one minute ago
HomeSubmit a program for being reviewedAdvertise on our websiteGet help on surfing our websitesSend us your feedbackGet information about our XML/RSS backend and how to use itBrowse the news archiveVisit our discussion forumVizitati forumul in limba romana



KLIP
  1. HOME
  2. SCIENCE
  3. TECHNOLOGY
  4. WEBMASTER
  5. SECURITY
  6. MICROSOFT
  7. LINUX
  8. APPLE
  9. GAMES
  10. TELECOMS
  11. REVIEWS
  12. LIFE & STYLE
  13. EDITORIALS
  14. INTERVIEWS
  15. RSS
Welcome!
Hello, Guest

Login if you have a Softpedia.com account.

Otherwise, register for one.

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

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
<?php
$archivename = "test.zip";
$zipobject = new ZipArchive();
$zipobject->open($archivename, ZIPARCHIVE::CREATE);
$zipobject->addFile("ex1.doc");
$zipobject->addFile("ex2.doc");
$zipobject->close();
echo "The new archive has been created";
?>


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.



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
 
Comments | Link here | Subscribe
Print | Send to friend
Today's News | Yesterday's News

Search:


13th March 2008, 16:47 GMT | Copyright (c) 2008 Softpedia | Contact:
Read by 2,468 user(s) | Rating: | 7 vote(s) so far | Cast your vote:
A Simple PHP Script to Create ZIP Archives on Windows - USER OPINIONS




We are sorry, there are no opinions available for this article.






SHARE YOUR OPINION ABOUT A Simple PHP Script to Create ZIP Archives on Windows

Since you are not logged on, your comments will have to be approved before being displayed.
Click here to login, or register.
Your Name:
Your Email:
Type in the result:
Your Opinion:
 


DO YOU WANT TO CONTACT US?  

If you have some comments or you want to send us some information you can send us an email directly to .
You can use the form below for the same purpose.
Your full name: (at least 3 characters)
Your email address: (at least 5 characters)
Message subject: (at least 5 characters)
Message text:
(at least 10 characters)
Type in the result:
 
 



© 2001 - 2008 Softpedia. All rights reserved.
Softpedia™ and Softpedia™ logo are registered trademarks of SoftNews NET SRL.
Copyright Information | Privacy Policy | Terms of Use | Contact Softpedia | Update your software | Archive