Sunday, May 17, 2015

CakePHP ZipArchive undedifined method

I want to type

class ZipController extends AppController {

$folder_path
= 'c:/Testaufgabe';
$zip_name
= 'c:/my_zipped_file.zip'; // to simiou kai to onoma tou arxeiou pou tha apothikeuti                

       
public function upload(){
        $za
= new ZipArchive();
        $res
= $za->open($zip_name, ZipArchive::CREATE);

       
if($res === TRUE){  
           
//$za->addFile($folder_path , basename($folder_path ));   // edo gia deuteri parametro theloume to onoma mono tou arxeiou
            $za
->addDir($folder_path, basename($folder_path));
            $za
->close();
       
}
       
else  {
            echo
'Could not create a zip archive';
       
}   }



public function addDir($path, $root){
//   $za->addEmptyDir($root);
   
//echo 'ok';
   
// $this->addDirDo($path, $root, $za);
}}

But when I call $za->addDir($folder_path, basename($folder_path));

it says that Call to undefined method ZipArchive::addDir()

I would like to have some help please

I use CAKEPHP V3


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: