Пример #1
0
 /**
  *
  * Move Function. Moves file from one location to another.
  * Once Moved the original file is unlinked.
  *
  * #### DO NOT USE TO MOVE UPLOADED file ####
  *
  * @param String $fromLocation Current Location of File MUST BE FULL LOCATION
  * @param String $toLocation Destination of File
  */
 public static function move($fromLocation, $toLocation, $permissions = 0777)
 {
     // If no Location is specified return false
     if (!$fromLocation || !$toLocation) {
         return false;
     }
     // If file does not exist
     if (!file_exists($fromLocation)) {
         return false;
     }
     // if ( copy ( $fromLocation , DOMAINRESOURCE . $toLocation ) ) {
     //   return true;
     // }
     //If AWS config exist try to move to S3
     if (Config::get('s3/key') && Config::get('s3/secret')) {
         if (Filemanager::MoveToS3($fromLocation, $toLocation)) {
             return true;
         }
     }
     // Check for symlinks
     if (is_link($fromLocation)) {
         return symlink(readlink($fromLocation), DOMAINRESOURCE . $toLocation);
     }
     // Simple copy for a file
     if (is_file($fromLocation)) {
         return copy($fromLocation, DOMAINRESOURCE . $toLocation);
     }
     // Make destination directory
     if (!is_dir(DOMAINRESOURCE . $toLocation)) {
         mkdir(DOMAINRESOURCE . $toLocation, $permissions);
     }
     // Loop through the folder
     $dir = dir($fromLocation);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         Filemanager::move("{$fromLocation}/{$entry}", "{$toLocation}/{$entry}", $permissions);
     }
     // Clean up
     $dir->close();
     return true;
 }
Пример #2
0
     }
     break;
 case 'getfolder':
     if ($fm->getvar('path')) {
         $response = $fm->getfolder();
     }
     break;
 case 'rename':
     if ($fm->getvar('old') && $fm->getvar('new')) {
         $response = $fm->rename();
     }
     break;
 case 'move':
     // allow "../"
     if ($fm->getvar('old') && $fm->getvar('new', 'parent_dir') && $fm->getvar('root')) {
         $response = $fm->move();
     }
     break;
 case 'delete':
     if ($fm->getvar('path')) {
         $response = $fm->delete();
     }
     break;
 case 'addfolder':
     if ($fm->getvar('path') && $fm->getvar('name')) {
         $response = $fm->addfolder();
     }
     break;
 case 'download':
     if ($fm->getvar('path')) {
         $fm->download();