• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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






0
jbrashear72
Asked:
jbrashear72
1 Solution
 
jstretchCommented:
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now