hey
I want to extract a file in yii
I wrote the following code to do it
public function trans()
{
$webroot = Yii::getPathOfAlias('webroot');
$zipfile=$webroot."/protected/test/Yiistrap.zip";
$zip = zip_open($zipfile);
$extract=$webroot. DIRECTORY_SEPARATOR . 'protected'. DIRECTORY_SEPARATOR . 'test'. DIRECTORY_SEPARATOR . 'newfolder';
if($zip)
{
if(!is_dir($extract))
{
mkdir($extract);
}
$myfile = Yii::app()->file->set($extract, true);
while ($zip_entry = zip_read($zip))
{
$myfile->permissions = '0777';
$fp = fopen($extract, "w");
if (zip_entry_open($zip, $zip_entry, "r"))
{
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
fwrite($fp,"$buf");
zip_entry_close($zip_entry);
fclose($fp);
break;
}
}
}
zip_close($zip);
}
But I got this error
fopen(C:/wamp/www/test\protected\test\newfolder) [<a href=‘function.fopen’>function.fopen</a>]: failed to open stream: Permission denied
I’m using Windows 7 and wamp server but applications on Linux servers will be in the future.
please help me