public function saveUploadedFiles(UploadedFilesInterface $files, $path = '/')
    {
        return $files->getUploadedFiles()->reduce(function ($uploaded, UploadedFile $file) use ($path) {
            $fileName = $file->getClientOriginalName();
            if ($this->disk->exists($path.$fileName)) {
                $this->errors[] = 'File '.$path.$fileName.' already exists in this folder.';

                return $uploaded;
            }

            if (!$file->storeAs($path, $fileName, [
                'disk' => $this->diskName,
                'visibility' => $this->access,
            ])) {
                $this->errors[] = trans('media-manager::messages.upload_error', ['entity' => $fileName]);

                return $uploaded;
            }
            $uploaded++;

            return $uploaded;
        }, 0);
    }
public function saveUploadedFiles(UploadedFilesInterface $files, $path = '/')
    {
        return $files->getUploadedFiles()->reduce(function ($uploaded, UploadedFile $file) use ($path) {
            $fileName = $file->getClientOriginalName();
            if ($this->disk->exists($path.$fileName)) {
                $this->errors[] = 'File '.$path.$fileName.' already exists in this folder.';

                return $uploaded;
            }

            if (!$file->storeAs($path, $fileName, [
                'disk' => $this->diskName,
                'visibility' => $this->access,
            ])) {
                $this->errors[] = trans('media-manager::messages.upload_error', ['entity' => $fileName]);

                return $uploaded;
            }
            $uploaded++;

            return $uploaded;
        }, 0);
    }
public function saveUploadedFiles ( UploadedFilesInterface $ files , $ path = '/' ) { return $ files -> getUploadedFiles ( ) -> reduce ( function ( $ uploaded , UploadedFile $ file ) use ( $ path ) { $ fileName = $ file -> getClientOriginalName ( ) ; if ( $ this -> disk -> exists ( $ path . $ fileName ) ) { $ this -> errors [ ] = 'File ' . $ path . $ fileName . ' already exists in this folder.' ; return $ uploaded ; } if ( ! $ file -> storeAs ( $ path , $ fileName , [ 'disk' => $ this -> diskName , 'visibility' => $ this -> access , ] ) ) { $ this -> errors [ ] = trans ( 'media-manager::messages.upload_error' , [ 'entity' => $ fileName ] ) ; return $ uploaded ; } $ uploaded ++ ; return $ uploaded ; } , 0 ) ; }
This method will take a collection of files that have been
uploaded during a request and then save those files to
the given path.

@param UploadedFilesInterface $files
@param string                 $path

@return int
This method will take a collection of files that have been uploaded during a request and then save those files to the given path .