cancel
Showing results for 
Search instead for 
Did you mean: 

Send file from one folder to another on ftp server in magento2

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Send file from one folder to another on ftp server in magento2

Hi All,

 

I want to transfer file from one location(i.e, /test) to another (/test/archive) on my FTP server. But i am facing issues. Can somebody help me in this.

 

$ftp = $this->getFtp();
        $localpath = $this->scopeConfig->getValue(self::FTP_FILE_LOC, $storeScope);
        $ftp->delete($localpath .'/'. $fileName);
        $localArchivepath = $this->scopeConfig->getValue(self::ARCHIVE_FTP_FILE_LOC, $storeScope);
        if (!$ftp->is_dir($localArchivepath)) {
            $ftp->mkdir($localArchivepath,0777);
        }

        $ftp->chdir($localArchivepath);
        $ftp->put($localpath.'/'.$fileName, file_get_contents($localArchivepath .'/'. $fileName));

But i am facing this error Call to a member function delete(), is_dir(), chdir() on boolean.

 

Can somebody suggest me. what can i do?

Magento Developer
Ankita Biswas