src/MediaUploader.php
public function upload()
    {
        $this->verifyFile();

        $model = $this->makeModel();

        $model->size = $this->source->size();
        $model->mime_type = $this->source->mimeType();
        $model->extension = $this->source->extension();

        $model->aggregate_type = $this->inferAggregateType($model->mime_type, $model->extension);

        $model->disk = $this->disk ?: $this->config['default_disk'];
        $model->directory = $this->directory;
        $model->filename = $this->generateFilename();

        $model = $this->handleDuplicate($model);

        if (is_callable($this->before_save)) {
            call_user_func($this->before_save, $model, $this->source);
        }

        $this->filesystem->disk($model->disk)->put($model->getDiskPath(), $this->source->contents());
        $model->save();

        return $model;
    }
public function upload()
    {
        $this->verifyFile();

        $model = $this->makeModel();

        $model->size = $this->source->size();
        $model->mime_type = $this->source->mimeType();
        $model->extension = $this->source->extension();

        $model->aggregate_type = $this->inferAggregateType($model->mime_type, $model->extension);

        $model->disk = $this->disk ?: $this->config['default_disk'];
        $model->directory = $this->directory;
        $model->filename = $this->generateFilename();

        $model = $this->handleDuplicate($model);

        if (is_callable($this->before_save)) {
            call_user_func($this->before_save, $model, $this->source);
        }

        $this->filesystem->disk($model->disk)->put($model->getDiskPath(), $this->source->contents());
        $model->save();

        return $model;
    }
public function upload ( ) { $ this -> verifyFile ( ) ; $ model = $ this -> makeModel ( ) ; $ model -> size = $ this -> source -> size ( ) ; $ model -> mime_type = $ this -> source -> mimeType ( ) ; $ model -> extension = $ this -> source -> extension ( ) ; $ model -> aggregate_type = $ this -> inferAggregateType ( $ model -> mime_type , $ model -> extension ) ; $ model -> disk = $ this -> disk ? : $ this -> config [ 'default_disk' ] ; $ model -> directory = $ this -> directory ; $ model -> filename = $ this -> generateFilename ( ) ; $ model = $ this -> handleDuplicate ( $ model ) ; if ( is_callable ( $ this -> before_save ) ) { call_user_func ( $ this -> before_save , $ model , $ this -> source ) ; } $ this -> filesystem -> disk ( $ model -> disk ) -> put ( $ model -> getDiskPath ( ) , $ this -> source -> contents ( ) ) ; $ model -> save ( ) ; return $ model ; }
Process the file upload.

Validates the source, then stores the file onto the disk and creates and stores a new Media instance.

@return \Plank\Mediable\Media
@throws \Plank\Mediable\Exceptions\MediaUpload\ConfigurationException
@throws \Plank\Mediable\Exceptions\MediaUpload\FileExistsException
@throws \Plank\Mediable\Exceptions\MediaUpload\FileNotFoundException
@throws \Plank\Mediable\Exceptions\MediaUpload\FileNotSupportedException
@throws \Plank\Mediable\Exceptions\MediaUpload\FileSizeException
Process the file upload .