复制后无法压缩文件(PHP)

时间:2013-11-01 07:10:36

标签: php copy ziparchive

我曾使用一些小文件尝试使用zip并且运行成功,但是在我更改目录并与复制片段混合后,它似乎根本无法运行。 我试过添加echo $ entry;在$ zip-> open(...)之前的一行,它显示结果。这意味着循环正在运作。但是当我尝试回显'C:\ Xeersoft \ inst01 \ webserver \ htdocs \ nll_latest \ nll000 \'。$ entry时,它根本没有显示任何结果。

这个php文件在nll_latest文件夹中。

这主要是一个php文件复制粘贴我的数据库并压缩它,稍后我需要传递数据链接供用户访问下载。

我是php新手,对不起,如果这个问题看起来很愚蠢。 =。=“

<?php

//Copy the Directory
$newfile = 'C:\Xeersoft\inst01\webserver\htdocs\nll_latest\nll000';
$file = 'C:\Xeersoft\inst01\database\data\nll000';

if(!is_dir($newfile)){
    mkdir($newfile,0777);
    }

$handle = opendir($file);
    while (false !== ($entry = readdir($handle))) {
        if($entry!='.' && $entry!='..'){
            if (!copy($file.'\\'.$entry, $newfile.'\\'.$entry)) {
                echo "failed to copy $entry...\n";
            }
        }
    }
closedir($handle);


//Zip the Directory
$zip = new ZipArchive;
$new = $zip->open('C:\Xeersoft\inst01\webserver\htdocs\nll_latest\latest.zip',ZipArchive::CREATE);

$handle2 = opendir('.\nll000');

if($new === TRUE) {
    while (false !== ($entry = readdir($handle2))) {
        if($entry!='.' && $entry!='..'){
            $zip->addFile('C:\Xeersoft\inst01\webserver\htdocs\nll_latest\nll000\\'.$entry, $entry);
        }
    }
}
$zip->close();
closedir($handle2);
?>

0 个答案:

没有答案
相关问题