Your HostICan Community  


Go Back   Your HostICan Community > Programming & Design > PHP / MySQL Assistance

PHP / MySQL Assistance We understand. Not all of you are experienced programmers, but some of you are highly skilled at coding. So we've set aside this forum so you can ask questions, and provide answers to the most commonly asked PHP / MySQL issues.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-10-2009, 04:44 PM
PrO.DeS PrO.DeS is offline
Junior Member
 
Join Date: Mar 2009
Posts: 3
Default ZIP archive on files in hosting through PHP

I think to use ZIP for making archive on few files in my hosting. Can I create a ZIP archive through PHP script?
Reply With Quote
  #2  
Old 09-10-2009, 05:30 PM
Vron's Avatar
Vron Vron is offline
Member
 
Join Date: Jan 2009
Posts: 73
Default Re: ZIP archive on files in hosting through PHP

PHP code contains comments for explanation:
PHP Code:
<?php
$zipname 
"archive.zip"// Name of the archive
$file1 "a-file"// The file that will be inserted into archive (must exist on the server)
$file1new "nuw-filename"//     The new name of the file in the archive
$zip = new ZipArchive(); // Class for creating a new ZIP archive
if($zip->open($zipnameZIPARCHIVE::CREATE)!==TRUE) {
die(
"Error");
}
$zip->addFile($file1$file1new);
$countfiles $zip->numFiles// The total number of files
$status $zip->status;
if(
$status == 0) { print "The archive was created successfullyTotal number of files: " $countfiles "---"; }
else { die(
"Error creating archive"); }
$zip-close();
?>
The class ZipArchive() required ZZIPlib
ZIPARCHIVE:: CREATE - create archive.
Reply With Quote
Reply

Tags
archive, files, hosting, php, zip

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:59 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Copyright © 2003 - 2008 HostICan. All Rights Reserved.