/** * @param $remotePathAndFilename */ public function delete($remotePathAndFilename) { if (!$this->ftp) { $this->initializeFtp(); } $remotePathAndFilename = '/' . $this->zone . '/' . $remotePathAndFilename; $remotePath = dirname($remotePathAndFilename); $dir = $this->ftp->findDirectoryByName($remotePath); if (substr_count($remotePath, '/') >= 2 && $dir && $this->ftp->directoryExists($dir)) { $this->ftp->delete($dir); } $file = $this->ftp->findFileByName($remotePathAndFilename); if ($this->ftp->fileExists($file)) { $this->ftp->delete($file); } }