这是我用来将文件夹(名称在$id
变量中)放入存档的脚本。
$sourcefolder="../uploads/fail/$id/";
$zipfilename="fordownload/$id.zip";
$timeout=5000;
$dirlist = new RecursiveDirectoryIterator($sourcefolder);
$filelist = new RecursiveIteratorIterator($dirlist);
ini_set('max_execution_time', $timeout);
$zip = new ZipArchive();
if ($zip->open("$zipfilename", ZipArchive::CREATE) !== TRUE) {
die ("Error");
}
foreach ($filelist as $key=>$value)
{
$zip->addFile(realpath($key), $key) or die ("Error");
}
$zip->close();
redict("$zipfilename",0);
问题是我只想把文件夹$id
放在存档中,没有前缀../uploads/fail/
,但我不知道怎么做。你能帮我吗?