Create directory with php: script copy common file into directory then! zip up the directory

Hey experts out there! Heres an easy 500 points..

I need to create a directory based on:
$path = "C:\Program Files\Apache Group\Apache\htdocs\sites";
\\ or $path = "\var\www\http\htdocs";

$dir = "\new_dir";

the copy over filess to the new directory from a common directory:
/home/commom_files


then tar and gzip new directory:
new_dir.tar.gz

Easy?
-J






LVL 3
jbrashear72Asked:
Who is Participating?
 
jstretchConnect With a Mentor Commented:
Creating a directory is easy:

//create the directory
$dir = "/new_dir";
$mode = 0700;
mkdir($dir, $mode);


Go here for a function that copies either a file or directory:
http://aidan.dotgeek.org/lib/?file=function.copyr.php


Go here for a function to compress files (shown in comments)
http://us4.php.net/manual/en/function.gzwrite.php

I'll change the code to do an entire directory....

0
 
jbrashear72Author Commented:
Looks good. Yea I need to zip the entire directory not just a file.
that would help.
 So far so good.
0
 
test75Commented:
I think you should firstly create a TAR file of your directory content and than compress (zip) it (tar.gz)
Maybe this can help you:
http://www.devshed.com/c/a/PHP/TAR-File-Management-With-PHP-Archive-Tar/
0
 
PromethylCommented:
You seem to be crossing OSes here. Is the source machine a Windows box and the target machine a *nix box? If so, should you use FTP to transfer the ZIP once it's done?

shell("tar -cfz mytargz");

Something like that. Should tar and then gzip the directory and everything in it, including respawning children nodes.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.