PHP Classes

File: FilesMover.php

Recommend this page to a friend!
  Classes of Naveen valecha   Files Mover   FilesMover.php   Download  
File: FilesMover.php
Role: Class source
Content type: text/plain
Description: FilesMover.php
Class: Files Mover
Copy or move files between directories
Author: By
Last change:
Date: 10 years ago
Size: 1,214 bytes
 

Contents

Class file image Download
<?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;
      }
    }
  }

}