LinuxHD
December 10th, 2011, 09:10
سلام دوستان
اسکریپت زیر رو مشاهده کنید :
<?
// increase script timeout value
ini_set("max_execution_time", 300000000);
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open("1.zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("/home/1/public_html/"));
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
// close and save archive
$zip->close();
echo "Archive created successfully.";
?>
کد بالا محتویات پوشه home/1/public_html/ رو در فایل 1.zip ذخیره می کنه
الان من نیاز دارم که این کد طوری تغییر بکنه که تمام اطلاعات موجود در public_html به جز یکی از فولدر ها مثلا images رو zip کنه یعنی همه رو zip کنه اما images رو نه
ممنون
اسکریپت زیر رو مشاهده کنید :
<?
// increase script timeout value
ini_set("max_execution_time", 300000000);
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open("1.zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("/home/1/public_html/"));
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
// close and save archive
$zip->close();
echo "Archive created successfully.";
?>
کد بالا محتویات پوشه home/1/public_html/ رو در فایل 1.zip ذخیره می کنه
الان من نیاز دارم که این کد طوری تغییر بکنه که تمام اطلاعات موجود در public_html به جز یکی از فولدر ها مثلا images رو zip کنه یعنی همه رو zip کنه اما images رو نه
ممنون