{@inheritdoc}

@param UploadedFile $source
358524
public function getAttributes($source): array
    {
        return [
            self::CLIENT_MIME_TYPE => $source->getClientMimeType(),
            self::CLIENT_NAME => $source->getClientOriginalName(),
            self::TMP_PATH => $source->getPathname(),
        ];
    }
15060
public function uploadFile(string $name, string $filename): void
    {
        $sourceFile = FilePath::parse($filename);
        if (!file_exists($sourceFile->__toString())) {
            throw new InvalidUploadedFileException('File "' . $sourceFile . '" does not exist.');
        }

        $destinationFile = tempnam(sys_get_temp_dir(), 'php');
        copy($sourceFile->__toString(), $destinationFile);

        $this->setUploadedFile(
            $name,
            new UploadedFile(
                FilePath::parse($destinationFile),
                $sourceFile->__toString(),
                filesize($destinationFile)
            )
        );
    }
275776
protected function upload(UploadedFile $file)
    {
        $this->renameIfExists($file);

        if (!is_null($this->storage_permission)) {
            return $this->storage->putFileAs($this->getDirectory(), $file, $this->name, $this->storage_permission);
        }

        return $this->storage->putFileAs($this->getDirectory(), $file, $this->name);
    }
584265
public function replaceInFile($source, $original, $replacement) {
    $source_path = $this->getRepoRoot() . '/' . $source;
    if ($this->getFileSystem()->exists($source)) {
      $contents = file_get_contents($source_path);
      $new_contents = str_replace($original, $replacement, $contents);
      file_put_contents($source_path, $new_contents);
    }
  }
947844
public function put($source = 'php://input', $sanitize = true)
    {
        if (is_null($source)) {
            $source = 'php://input';
        }

        $source = @fopen($source, 'r');

        if (!is_resource($source)) {
            throw new InvalidArgumentException('Expected parameter 1 to be an open-able resource');
        }

        $data = null;

        while ($buffer = fread($source, 1024)) {
            $data .= $buffer;
        }

        fclose($source);

        return $sanitize ? filter_var($data, FILTER_SANITIZE_STRING) : $data;
    }
824502
private function uploadOne(UploadedFile $file)
    {
        try {
            $validator = new FileValidator([$this->_config]);
            if ($validator->validate($file, $error)) {
                $fileInfo = $file->save();
                $result = [
                    'name' => Html::encode($fileInfo->filename),
                    'url' => $fileInfo->getUrl(),
                    'path' => $fileInfo->path,
                    'extension' => $file->extension,
                    'type' => $fileInfo->type,
                    'size' => $fileInfo->size
                ];
                if ($this->onlyImage !== true) {
                    $result['filename'] = $result['name'];
                }
            } else {
                $result = [
                    'error' => $error
                ];
            }
        } catch (Exception $e) {
            $result = [
                'error' => $e->getMessage()
            ];
        }
        return $result;
    }
516514
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
    {
        $source->uid = $source->filepath = sha1($source->name);
        $source->timestamp = 0;
        $source->exists = true;
    }
1213154
protected function onSetUploadedFile(
        /** @noinspection PhpUnusedParameterInspection */
        UploadedFileInterface $uploadedFile = null
    ): void {
        if ($this->isEmpty() && $this->isRequired()) {
            $this->setError('Missing file');
        }
    }
766343
public function uploadFile(UploadedFile $file)
    {
        $path =   $this->env . '/'  . md5(time() . random_int(1,100000)) . '.'. $file->guessClientExtension();
        /** @var Result $result */
        $result = $this->client->putObject([
            'ACL' => 'public-read',
            'Bucket' => $this->bucketName,
            'SourceFile' => $file->getRealPath(),
            'Key' => $path
        ]);

        return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
    }
646936
protected function validateUpload(UploadedFileInterface $file): void
    {
        // Handle bad filenames.
        $filename = $file->getClientFilename();

        if (!Utils::checkFilename($filename)) {
            $grav = Grav::instance();
            throw new \RuntimeException(
                sprintf($grav['language']->translate('PLUGIN_FORM.FILEUPLOAD_UNABLE_TO_UPLOAD', null, true), $filename, 'Bad filename')
            );
        }
    }
885256
private function uploadFile(UploadedFile $file)
    {
        /** @var FileStorage $fileStorage */
        $fileStorage = Yii::$app->get('fileStorage');

        $filename = $fileStorage->saveUploadedFile($file);

        return $fileStorage->put($filename, $file->name);
    }
157915
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
    {
        $source->filepath = $this->buildFilepath($source, $_template);

        if ($source->filepath !== false) {
            if (is_object($source->smarty->security_policy)) {
                $source->smarty->security_policy->isTrustedResourceDir($source->filepath);
            }

            $source->uid = sha1($source->filepath);
            if ($source->smarty->compile_check) {
                $source->timestamp = @filemtime($source->filepath);
                $source->exists = !!$source->timestamp;
            }
        }
    }
1348915
private function loadResourceFromType($source)
    {

        $mime = null;
        extract(getimagesize($source));

        $fn = sprintf('imagecreatefrom%s', $type = substr($mime, strpos($mime, '/') + 1));

        if (!function_exists($fn)) {
            $this->error = sprintf('%s is not a supported image type', $mime);
            $this->clean();

            throw new \InvalidArgumentException(sprintf('Unsupported image format %s', $mime));
        }

        $this->source = $this->loader->load($source);
        $this->outputType = $mime;

        return call_user_func($fn, $this->source);
    }
1230120
public function addSource($filename, $source, $fileData)
    {
        $this->_sources[substr($filename, strlen($this->_phpdoctor->sourcePath()) + 1)] = array(
            $source, $fileData
        );
    }
272898
protected function saveInStorage(HCResource $resource, UploadedFile $file): void
    {
        if (Storage::disk($resource->disk)->exists($resource->path)) {
            logger()->warning('file already exists with this name: ' . $resource->safe_name);

            return;
        }

        $file->storeAs($this->uploadPath, $resource->safe_name, $resource->disk);
    }
1263189
public function addDependency(Source $source)
    {
        if ($this->parent !== null) {
            $this->parent->addDependency($source);
        }
        $tplId = $source->tplId;
        if ($source->type == 'string' || $source->type == 'base64') {
            $this->property['dependency'][$tplId] = $source->type;
            return;
        }
        $this->property['dependency'][$tplId] = [
            0 => $source->type,
            1 => $source->tplname,
            2 => $source->timestamp,
        ];
    }
1001834
public static function load($source)
    {
        self::$variables = is_array($source) ? $source : require $source;
        self::$isLoaded = true;

        self::checkRequiredVariables();
    }