Plank\Mediable\MediaUploader::upload PHP Method

upload() public method

Validates the source, then stores the file onto the disk and creates and stores a new Media instance.
public upload ( ) : Media
return Media
    public function upload()
    {
        $this->verifySource();
        $model = $this->makeModel();
        $model->size = $this->verifyFileSize($this->source->size());
        $model->mime_type = $this->verifyMimeType($this->source->mimeType());
        $model->extension = $this->verifyExtension($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();
        $this->verifyDestination($model);
        $this->filesystem->disk($model->disk)->put($model->getDiskPath(), $this->source->contents());
        $model->save();
        return $model;
    }