public function importFile($localPath, FileInterface $folder = null)
    {
        if(!$folder->isDir()){
            throw new RuntimeException('Files can only be moved into directories');
        }
        //$fileName = $uploadedFile->getClientOriginalName();

        $fileName = basename($localPath);

        $targetPath = $folder ? $folder->getPath() . "$fileName" : $fileName;

        $this->files->move($localPath, $targetPath);

        $absPath = $this->mapper->absolutePath($targetPath);

        $file = $this->createFromPath($targetPath);

        if ($folder) {
            $file->setDir($folder);
            $folder->addChild($file);
        }

        $this->save($file);

        return $file;
    }
public function importFile($localPath, FileInterface $folder = null)
    {
        if(!$folder->isDir()){
            throw new RuntimeException('Files can only be moved into directories');
        }
        //$fileName = $uploadedFile->getClientOriginalName();

        $fileName = basename($localPath);

        $targetPath = $folder ? $folder->getPath() . "$fileName" : $fileName;

        $this->files->move($localPath, $targetPath);

        $absPath = $this->mapper->absolutePath($targetPath);

        $file = $this->createFromPath($targetPath);

        if ($folder) {
            $file->setDir($folder);
            $folder->addChild($file);
        }

        $this->save($file);

        return $file;
    }
public function importFile ( $ localPath , FileInterface $ folder = null ) { if ( ! $ folder -> isDir ( ) ) { throw new RuntimeException ( 'Files can only be moved into directories' ) ; } //$fileName = $uploadedFile->getClientOriginalName(); $ fileName = basename ( $ localPath ) ; $ targetPath = $ folder ? $ folder -> getPath ( ) . "$fileName" : $ fileName ; $ this -> files -> move ( $ localPath , $ targetPath ) ; $ absPath = $ this -> mapper -> absolutePath ( $ targetPath ) ; $ file = $ this -> createFromPath ( $ targetPath ) ; if ( $ folder ) { $ file -> setDir ( $ folder ) ; $ folder -> addChild ( $ file ) ; } $ this -> save ( $ file ) ; return $ file ; }
Import a local file into the FileDB

@param string $localPath
@param FileInterface $folder (optional)

@return FileInterface The new file
Import a local file into the FileDB