jay3ld Posted November 25, 2006 Share Posted November 25, 2006 Hello,I am trying to figure out how to insert/create folders into a zip created by php and enter files into that folder. I never used php zip functions or anything like that So I am running off what I read around.Basicly if you want to know what I am trying to do is after my website gets backups of each of my databases in mysql and put them into a folder I want to zip the folder up and then mail it.. I can get the backups and mail files but its the zip part I am trying to figure out how to do.The reason I am trying to do this is my mysql databases are getting so big its starting to get hard to open one big text file when I need to get something that I lost back into my mysql database. So doing multiple Files for each of my databases (and optional for each table in database when I need to know that) should help me out with opening files..This is what I wrote as a test..In the folder there are 3 files like thisdatabase1.sqldatabase2.sqldatabase3.sql[code]<?php$path = '/home/user/testlocal/public_html/Mysql-backups/backups';//Open the Direcotry were the files are saved.$dir_handle = opendir($path) or die("Unable to open $path");//Read the Direcotry.while ($file = readdir($dir_handle)){ //Ignore any files starting with . or index if(substr($file, 0, 1) == '.' || substr($file, 0, 5) == 'index') continue; //Get the Extension out of the name and test it.. if(substr($file, -3, 3) == 'sql') $files[$i++] = $file; else continue;}//Open the file$gz = gzopen('DatabaseBackups.gz','w9');//Instert Into the zip file. Repeating process for each.for ($a = 0, $i => $a, $a++) gzwrite($gz, $files[$i]);//Close it up.gzclose($gz);?>[/code] Link to comment https://forums.phpfreaks.com/topic/28400-php-filefolder-zipping/ Share on other sites More sharing options...
The Little Guy Posted November 25, 2006 Share Posted November 25, 2006 http://us3.php.net/zipThere are links and descriptions below all the examples on this page.This may help toohttp://us3.php.net/manual/en/function.ziparchive-addfile.php Link to comment https://forums.phpfreaks.com/topic/28400-php-filefolder-zipping/#findComment-129955 Share on other sites More sharing options...
jay3ld Posted November 25, 2006 Author Share Posted November 25, 2006 hmm.. I messed around with those and nothing helped..still not working.. Link to comment https://forums.phpfreaks.com/topic/28400-php-filefolder-zipping/#findComment-130157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.