Example #1
0
 /**
  * function copy file to $destination path
  * 		(ex: copyFile('/home/bum/downloads/'))
  *
  * @param string $destination destination file path
  *
  * @return bool file copy result
  */
 function copyFile($oFile, $destination)
 {
     if (empty($oFile)) {
         $this->farrErrors[] = "File not set";
         return false;
     }
     if (empty($destination)) {
         $this->farrErrors[] = "File destination path not set";
         return false;
     }
     if ($destination[strlen($destination) - 1] != "/" && $destination[strlen($destination) - 1] != "\\") {
         $destination .= "/";
     }
     $arrProperty = $oFile->getFileProperty();
     if (@copy($oFile->getFilePath() . $oFile->getFileName(), $destination . $oFile->getFileName())) {
         $arrProperty['filePath'] = $destination . $oFile->getFileName();
         $oNewFile = new File();
         $oNewFile->initializeByPropertyArray($arrProperty);
         return $oNewFile;
     } else {
         $this->farrErrors[] = "File copy error";
         return false;
     }
 }