Folder is not writable while copying one folder to another

I am creating an application which copies folder from one source to destination. I am using CakePHP folder API for that. I am using Flder API copy function with mode 777, But it return an error that folder is not writable. How to do that please help.

First, what operating system are you working on; Localhost on windows or linux?

Second, does the regular php folder creation with mkdir work okay?

Third, can you show us the code you’ve been using for it so far?

First of all thanks for your reply.
I am using Ubuntu 14.
My code runs perfect for windows system.
Below is my code which I have done so far:

function copy_Folder(){
        $this->layout = 'ajax';
        if(isset($this->request->data) && !empty($this->request->data)){
            $addon = $this->request->data['addon'];
            $arr = array();
            $addonArcfolder = $this->addonZipFile[$addon];
            $addon_folder = new Folder(WEB_ROOT.DS.$addonArcfolder, true, 0777);
                $dest = new Folder(PLUGIN, true, 0777);
				$dest->chmod(PLUGIN, '0777', true);
                $suc = $addon_folder->copy(array(
                    'to' => $dest->pwd(),
                    'from' => $addon_folder->path,
                    'mode' => 0777,
                    'skip' => array(),
                    'scheme' => Folder::OVERWRITE,
                    'recursive' => true
                    $addon_Delfolder = new Folder(WEB_ROOT.DS.$addonArcfolder, true, 0777);
                    $zipFile = $this->addonZipFile[$addon].'.zip';
                    $webroot_dir = new Folder(WEB_ROOT);
                    $zipfilespresent = $webroot_dir->find($zipFile);
                    $zipF = new File($webroot_dir->pwd() . DS . $zipfilespresent[0], true, 0777);
                    $addonNm = $this->addonName[$addon];
                    $arr['success'] = '1';
                    $arr['msg'] = "Please click on verify to check it is installed properly or not.";
                    $arr['error'] = '1';
                    $arr['msg'] = 'Can not copy the folder.';
                $arr['error'] = '1';
                $arr['msg'] = 'No add-on Folder is present in the zip file.';
            echo json_encode($arr);exit;


Yeah, as far as I can tell the code should work fine, so I suspect it has to do with the directory ownerships. Have you made sure that the folders you’re working with belong to the right user (normally www-data)?

The directory has the login user owner. I tried to change the owner of the directory to ‘apache’ user using chown function.
But all in vain… What to do Please suggest something I don’t know what to do now…