I am creating zip file using ZipArchive in php. code-
$path = Yii::getPathOfAlias('webroot').'/quickshopimages/productimage/';
$zip =new ZipArchive();
$zip->open('test.zip', ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
$iterator=new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path),
RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file)
{
if($file->isDir())
{
echo strtoupper($file->getRealpath()), PHP_EOL.'<br/>';$file .'/');
$zip->addEmptyDir(str_replace(strtoupper($file->getRealpath()) . '/', '',
$file . '/'));
}
else
{
$zip->addFile($file);
}
}
$zip->close();
But here problem is that when I create zip its folder structure sets as
C:\Program Files (x86)\EasyPHP-5.3.5.0\www\quickshop\trunk\quickshopimages\productimage\male\shirts\Ethnic\1
and my main root directory is from "productimage\male\shirts\Ethnic\1". So, how can start zip folder from "productimage" as root here?
Thanks in advance and sorry for English