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:

then tar and gzip new directory:


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:

Go here for a function to compress files (shown in comments)

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

jbrashear72Author Commented:
Looks good. Yea I need to zip the entire directory not just a file.
that would help.
 So far so good.
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:
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.
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.