<?php
/**
* The class is use to move and copy files from one directory to another directory.
* @author Naveen Valecha<valecha29@gmail.com>
*/
class FilesMover {
public function Move($source, $destination) {
if (file_exists($source)) {
$log = new Log();
if (copy($source, $destination)) {
$data = 'Success : file copied successfully from ' . $source . ' to ' . $destination;
$log->write($data);
if (unlink($source)) {
$log->write('Success : '.$source . ' deleted successfully');
}
return TRUE;
}
else {
$data = 'Error : failed to copy file from ' . $source . ' to ' . $destination;
$log->write($data);
return FALSE;
}
}
}
public function Copy($source, $destination) {
if (file_exists($source)) {
$log = new Log();
if (copy($source, $destination)) {
$data = 'Success : file copied successfully from ' . $source . ' to ' . $destination;
$log->write($data);
return TRUE;
}
else {
$data = 'Error : failed to copy file from ' . $source . ' to ' . $destination;
$log->write($data);
return FALSE;
}
}
}
}
|