public function upload(Request $request, $dirId)
    {

        try {

            $folder = $this->getDirOrFail($dirId);

            if (!$request->hasFile('uploadedFile')) {
                throw new RuntimeException('Uploaded File not found');
            }

            $uploadedFile = $request->file('uploadedFile');

            /** @var UploadedFile $uploadedFile */
            $uploadedFile = is_array($uploadedFile) ? $uploadedFile[0] : $uploadedFile;

            $fileName = $uploadedFile->getClientOriginalName();

            $newPath = $this->getTempDir() . '/' . $fileName;

            $uploadedFile->move($this->getTempDir(), $fileName);

            $this->fileDB->importFile($newPath, $folder);

            return $this->redirectTo('index', $folder->getId());

        } catch(FileException $e) {
            $this->flashMessage('upload-failed','danger');
        } catch(RuntimeException $e) {
            $this->flashMessage('uploaded-file-missing','danger');
        }

        return $this->redirectTo('index');

    }
public function upload(Request $request, $dirId)
    {

        try {

            $folder = $this->getDirOrFail($dirId);

            if (!$request->hasFile('uploadedFile')) {
                throw new RuntimeException('Uploaded File not found');
            }

            $uploadedFile = $request->file('uploadedFile');

            /** @var UploadedFile $uploadedFile */
            $uploadedFile = is_array($uploadedFile) ? $uploadedFile[0] : $uploadedFile;

            $fileName = $uploadedFile->getClientOriginalName();

            $newPath = $this->getTempDir() . '/' . $fileName;

            $uploadedFile->move($this->getTempDir(), $fileName);

            $this->fileDB->importFile($newPath, $folder);

            return $this->redirectTo('index', $folder->getId());

        } catch(FileException $e) {
            $this->flashMessage('upload-failed','danger');
        } catch(RuntimeException $e) {
            $this->flashMessage('uploaded-file-missing','danger');
        }

        return $this->redirectTo('index');

    }
public function upload ( Request $ request , $ dirId ) { try { $ folder = $ this -> getDirOrFail ( $ dirId ) ; if ( ! $ request -> hasFile ( 'uploadedFile' ) ) { throw new RuntimeException ( 'Uploaded File not found' ) ; } $ uploadedFile = $ request -> file ( 'uploadedFile' ) ; /** @var UploadedFile $uploadedFile */ $ uploadedFile = is_array ( $ uploadedFile ) ? $ uploadedFile [ 0 ] : $ uploadedFile ; $ fileName = $ uploadedFile -> getClientOriginalName ( ) ; $ newPath = $ this -> getTempDir ( ) . '/' . $ fileName ; $ uploadedFile -> move ( $ this -> getTempDir ( ) , $ fileName ) ; $ this -> fileDB -> importFile ( $ newPath , $ folder ) ; return $ this -> redirectTo ( 'index' , $ folder -> getId ( ) ) ; } catch ( FileException $ e ) { $ this -> flashMessage ( 'upload-failed' , 'danger' ) ; } catch ( RuntimeException $ e ) { $ this -> flashMessage ( 'uploaded-file-missing' , 'danger' ) ; } return $ this -> redirectTo ( 'index' ) ; }
Upload a file into the file db.

@param Request $request
@param int     $dirId

@return RedirectResponse
Upload a file into the file db .