Upload file from http

@param UploadedFile $uploadedFile

@return bool
192801
public function upload($uploadedFile)
    {
        if ($uploadedFile->isValid()) {
            $this->getFilesystem()->putFileAs(
                dirname($this->getPath()),
                $uploadedFile,
                $this->getName()
            );

            return true;
        } else {
            $this->errors['upload'] = $uploadedFile->getErrorMessage();
        }

        return false;
    }
668846
public function upload(File $file, UploadedFile $upload, $contents)
    {
        $response = $this->api->post('upload', [
            'json' => [
                'type'  => 'base64',
                'image' => base64_encode($contents),
            ],
        ]);

        // successful upload, let's get the generated URL
        if ($response->getStatusCode() == 200) {
            $meta = Arr::get(json_decode($response->getBody(), true), 'data', []);

            $link = Arr::get($meta, 'link');

            $file->url = preg_replace('/^https?:/', null, $link);
            $file->remote_id = Arr::get($meta, 'id');
        }

        if ($response->getStatusCode() != 200 || empty($file->url)) {
            return false;
        }

        return $file;
    }
1109835
public function handle(UploadedFile $uploadedFile) {
        $this->setUsed(true);
        $this->validateError($uploadedFile);
        $this->validateExtension($uploadedFile);
        $handler = $this->getHandler();
        $handler($uploadedFile);
    }
985616
private static function parseUploadedFiles(array $uploadedFiles) {
        $parsed = array();

        foreach ($uploadedFiles as $field => $uploadedFile) {
            if (!isset($uploadedFile['error'])) {
                if (is_array($uploadedFile)) {
                    $parsed[$field] = static::parseUploadedFiles($uploadedFile);
                }
                continue;
            }
            $parsed[$field] = array();

            if (!is_array($uploadedFile['error'])) {
                $parsed[$field] = new static(
                        $uploadedFile['tmp_name'], isset($uploadedFile['name']) ? $uploadedFile['name'] : null, isset($uploadedFile['type']) ? $uploadedFile['type'] : null, isset($uploadedFile['size']) ? $uploadedFile['size'] : null, $uploadedFile['error'], true
                );
            } else {
                foreach ($uploadedFile['error'] as $fileIdx => $error) {
                    $parsed[$field][] = new static(
                            $uploadedFile['tmp_name'][$fileIdx], isset($uploadedFile['name']) ? $uploadedFile['name'][$fileIdx] : null, isset($uploadedFile['type']) ? $uploadedFile['type'][$fileIdx] : null, isset($uploadedFile['size']) ? $uploadedFile['size'][$fileIdx] : null, $uploadedFile['error'][$fileIdx], true
                    );
                }
            }
        }

        return $parsed;
    }
309530
public function createUmbrellaFile(UploadedFile $file, $upload = false)
    {
        $umbrellaFile = new UmbrellaFile();
        $umbrellaFile->name = $file->getClientOriginalName();
        $umbrellaFile->md5 = md5_file($file->getRealPath());
        $umbrellaFile->mimeType = $file->getMimeType();
        $umbrellaFile->size = $file->getSize();

        if ($upload) {
            $umbrellaFile->path = $this->upload($file);
        } else {
            $umbrellaFile->file = $file;
        }
        return $umbrellaFile;
    }
648065
private function parseFile($uploadedFile)
    {
        $item = [];

        if (is_array($uploadedFile)) {
            if (!is_array($uploadedFile['error'])) {
                $item[] = new UploadedFile(
                    $uploadedFile['tmp_name'],
                    isset($uploadedFile['name']) ? $uploadedFile['name'] : null,
                    isset($uploadedFile['type']) ? $uploadedFile['type'] : null,
                    isset($uploadedFile['size']) ? $uploadedFile['size'] : null,
                    $uploadedFile['error']
                );
            } else {
                foreach ($uploadedFile['error'] as $fieldIndex => $void) {
                    $item[] = new UploadedFile(
                        $uploadedFile['tmp_name'][$fieldIndex],
                        isset($uploadedFile['name']) ? $uploadedFile['name'][$fieldIndex] : null,
                        isset($uploadedFile['type']) ? $uploadedFile['type'][$fieldIndex] : null,
                        isset($uploadedFile['size']) ? $uploadedFile['size'][$fieldIndex] : null,
                        $uploadedFile['error'][$fieldIndex]
                    );
                }
            }
        }

        return $item;
    }
44464
private function getUploadedOriginalFileProperties(UploadedFile $uploadedFile)
    {
        $this->results['original_filename'] = $uploadedFile->getClientOriginalName();
        $this->results['original_filepath'] = $this->getRelativePath($uploadedFile->getRealPath());
        $this->results['original_filedir'] = $uploadedFile->getRealPath();
        $this->results['original_extension'] = $uploadedFile->getClientOriginalExtension();
        $this->results['original_filesize'] = (int) $uploadedFile->getSize();
        $this->results['original_mime'] = $uploadedFile->getMimeType();

        return $this;
    }
433662
public static function createFromUploadedFile(UploadedFile $file)
    {
        $size = getimagesize($file->getRealPath());

        $image = new Image($file->guessExtension());
        $image->setOriginalFilename($file->getClientOriginalName());
        $image->setMimeType($file->getMimeType());
        $image->setSize(filesize($file->getRealPath()));
        $image->setWidth($size[0]);
        $image->setHeight($size[1]);

        return $image;
    }
35362
public static function uploadImage(UploadedFile $uploadedFile, $context, $storage = 'local', $fileName = null)
    {
        $file = Facades\File::get($uploadedFile);
        /** @var Processor $processor */
        $processor = app('icr.processor');
        return $processor->upload(
            $context,
            $file,
            $uploadedFile->getClientOriginalExtension(),
            Facades\Storage::disk($storage),
            $fileName
        );
    }
830888
public static function process($uploadedFile, $path)
    {
        if (!$uploadedFile || $uploadedFile->hasError) {
            throw new Exception('Failed to upload file');
        }
        $chunk = (int)Yii::$app->request->getBodyParam('chunk', 0);
        $totalChunks = (int)Yii::$app->request->getBodyParam('chunks', 0);
        $out = fopen("$path.part", $chunk == 0 ? 'wb' : 'ab');
        if (!$out) {
            throw new Exception('Failed to open output stream');
        }
        // Read binary input stream and append it to temporary .part file
        $in = fopen($uploadedFile->tempName, 'rb');
        if ($in) {
            while ($buff = fread($in, 4096)) {
                fwrite($out, $buff);
            }
        } else {
            throw new Exception('Failed to open input stream');
        }
        fclose($in);
        fclose($out);
        unlink($uploadedFile->tempName);
        // Check if all chunks have been processed
        if (!$totalChunks || $chunk == $totalChunks - 1) {
            // Strip the temp .part suffix off
            rename("$path.part", $path);
            return true;
        }
        return false;
    }
351662
protected function onSetUploadedFile(?UploadedFileInterface $uploadedFile = null): void
    {
        $this->file = $uploadedFile;

        parent::onSetUploadedFile();
    }
842762
public function getUploadPath(UploadedFile $file)
    {
        if (! is_callable($this->uploadPath)) {
            return $this->defaultUploadPath($file);
        }

        return call_user_func($this->uploadPath, $file);
    }
39118
public function uploadFile()
    {
        if (!$this->request->files->has('file')) {
            return false;
        }
        $file   = $this->request->files->get('file');
        $upload = rtrim($this->uploadDir, '/');
        if (!is_dir($upload)) {
            mkdir($upload, 0777, true);
        }
        $file->move(realpath($upload), $file->getClientOriginalName());

        return sprintf('/%s/%s', pathinfo($upload, PATHINFO_BASENAME),
            pathinfo($file->getClientOriginalName(), PATHINFO_BASENAME));
    }
40292
public function upload(File $file, UploadedFile $upload, $contents)
    {
        $this->generateFilename($file);

        $method = 'write';

        if (is_resource($contents) && get_resource_type($contents) == 'stream') {
            $method = 'writeStream';
        }

        $meta = $this->adapter->{$method}($file->path, $contents, new Config());

        if (!$meta) {
            return false;
        }

        $this->meta = $meta;

        $this->generateUrl($file);

        return $file;
    }
1010463
public function move($toFile)
    {
        if ($this->error == UPLOAD_ERR_OK) {
            return move_uploaded_file($this->tmpName, $toFile);
        } else {
            return false;
        }
    }
95682
public function upload(\Symfony\Component\HttpFoundation\File\UploadedFile $file) {
    
    // We simply move the uploaded file to the target directory
    $result = $file->move(\Config::get('plupload::plupload.upload_dir'), $file->getClientOriginalName());

    // Return the result of the upload
    return $this->respond(array('OK' => ($result) ? 1 : 0));
  }
336521
protected function uploadAndDeleteOriginal(UploadedFile $file)
    {
        $this->renameIfExists($file);

        $path = null;

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

        $this->destroy();

        return $path;
    }