Devise\Media\Files\Filesystem::rename PHP Method

rename() public method

Relocates a path from a location to a new location
public rename ( string $path, string $target )
$path string
$target string
    public function rename($path, $target)
    {
        $basedir = dirname($target);
        if (!is_dir($basedir)) {
            mkdir($basedir, 0755, $recursive = true);
        }
        $this->move($path, $target);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Renames an uploaded file
  *
  * @param  string $filepath
  * @param  string $newpath
  * @return void
  */
 public function renameUploadedFile($filepath, $newpath)
 {
     if ($this->Caption->exists($this->basepath . $filepath)) {
         $oldCptPath = $this->MediaPaths->imageCaptionPath($this->basepath . $filepath);
         $newCptPath = $this->MediaPaths->imageCaptionPath($this->basepath . $newpath);
         $this->Filesystem->rename($oldCptPath, $newCptPath);
     }
     return $this->Filesystem->rename($this->basepath . $filepath, $this->basepath . $newpath);
 }
All Usage Examples Of Devise\Media\Files\Filesystem::rename