Load the file attributes submitted by form and return the updated file model.

@param File $file
@param string $name
@return File - after loading from request url
4076
public static function loadFile( $file, $name ) {

		if( !isset( $file ) ) {

			$file	= new File();
		}

		$file->load( Yii::$app->request->post(), $name );

		return $file;
	}
1212017
public static function load($name) {
		if( empty($_FILES[$name]['name']) ) { /*text('load() Name not found'); */return null; }
		if( is_array($_FILES[$name]['name']) ) {
// 			text('load() Name is an array');
// 			$r	= array();
			return static::loadPath($_FILES[$name]);
// 			foreach( $_FILES[$name]['name'] as $ind => $fileName ) {
// 				if( empty($fileName) ) { continue; }
// 				static::loadPath($r, $_FILES[$name]);
// // 				$r[] = new static($fileName, $_FILES[$name]['size'][$ind], $_FILES[$name]['tmp_name'][$ind], $_FILES[$name]['error'][$ind]);
// 			}
// 			return $r;
		}
// 		text('load() Name is a single object');
		return new static($_FILES[$name]['name'], $_FILES[$name]['size'], $_FILES[$name]['tmp_name'], $_FILES[$name]['error']);
// 		return !empty($_FILES[$name]['name']) ? new static($_FILES[$name]['name'], $_FILES[$name]['size'], $_FILES[$name]['tmp_name'], $_FILES[$name]['error']) : null;
	}
188630
public function file(string $file, string $name = null, bool $download = true): ResponseInterface
    {
        if (!\is_file($file)) {
            throw new \LogicException("File '$file' doesn't exist.");
        }

        $extension = \substr($file, \strrpos($file, '.') + 1);
        $this->header->set('Content-Type',
            MimeType::getMimeType($extension) ?? 'application/octet-stream'
        );

        $disposition = $download ? Header::DISPOSITION_ATTACHMENT : Header::DISPOSITION_INLINE;
        $this->header->set('Content-Disposition',
            $this->header->makeDisposition($disposition, $name, \basename($file))
        );

        $size = $length = \filesize($file);

        $this->header->set('Accept-Ranges', 'bytes');
        if (\preg_match('#^bytes=(\d*)-(\d*)\z#', $this->request->header('Range'), $matches)) {
            list(, $start, $end) = $matches;

            if ($start === '') {
                $start = \max(0, $size - $end);
                $end = $size - 1;
            } elseif ($end === '' || $end > $size - 1) {
                $end = $size - 1;
            }

            if ($end < $start) {
                return $this->empty(416); // requested range not satisfiable
            }

            $this->setStatus(206);
            $this->header->set('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $size);
            $length = $end - $start + 1;
        } else {
            $this->header->set('Content-Range', 'bytes 0-' . ($size - 1) . '/' . $size);
        }

        $this->header->set('Content-Length', $length);

        $this->app->emitter(
            $this->emitter ?? Emitter\SapiStream::class
        );

        return $this->response(
            Factory::streamFromFile($file, 'rb')
        );
    }
201137
protected function downloadResponse($file, $name = null, array $headers = array())
	{
		$response = new BinaryFileResponse($file, 200, $headers, true, 'attachment');

		if ($name !== null) {
			return $response->setContentDisposition('attachment', $name, Str::ascii($name));
		}

		return $response;
	}
357077
protected function loadFile($name)
    {
        $blueprint = new Blueprint($name);

        if (\is_array($this->search) || \is_object($this->search)) {
            // Page types.
            $blueprint->setOverrides($this->search);
            $blueprint->setContext('blueprints://pages');
        } else {
            $blueprint->setContext($this->search);
        }

        return $blueprint->load()->init();
    }
287167
protected function unifyFile($name, $file)
	{
		// storage for results
		$data = array();

		// loop over the file array
		foreach ($file['name'] as $key => $value)
		{
			// we're not an the end of the element name nesting yet
			if (is_array($value))
			{
				// recurse with the array data we have at this point
				$data = array_merge(
					$data,
					$this->unifyFile($name.'.'.$key,
						array(
							'filename' => null,
							'name'     => $file['name'][$key],
							'type'     => $file['type'][$key],
							'tmp_name' => $file['tmp_name'][$key],
							'error'    => $file['error'][$key],
							'size'     => $file['size'][$key],
						)
					)
				);
			}
			else
			{
				$data[] = array(
					'filename' => null,
					'element'  => $name.'.'.$key,
					'name'     => $file['name'][$key],
					'type'     => $file['type'][$key],
					'tmp_name' => $file['tmp_name'][$key],
					'error'    => $file['error'][$key],
					'size'     => $file['size'][$key],
				);
			}
		}

		return $data;
	}
720162
public function loadFile($file)
    {
        if (!file_exists($file)) {
            throw new LoaderException("Requested YAML file '{$file}' doesn't exist");
        }

        $contents = file_get_contents($file);

        if ($this->useSymfony) {
            try {
                // Apparently parser keeps references to the things it parses? As such, we want to create a new parser
                // each time (uch)
                $parser = new Parser();
                return $parser->parse($contents);
            } catch (ParseException $e) {
                throw new LoaderException("Could not load the YAML file '{$file}': ".$e->getMessage());
            }
        }

        $data = yaml_parse($contents);
        if (!is_array($data)) {
            throw new LoaderException("Requested YAML file '{$file}' does not parse to an array");
        }

        return $data;
    }
185301
protected function downloadFile($file, $name = null)
    {
        if(file_exists($file) && is_file($file) && is_readable($file)) {
            $mime_type = mime_content_type($file);
            if(in_array($mime_type, ['image/gif', 'image/jpeg', 'image/png'])) {
                $exif_type = exif_imagetype($file);
                $img_ext = image_type_to_extension($exif_type);
                if($img_ext == '.jpeg') {
                    $img_ext = '.jpg';
                }
                switch($exif_type) {
                    case IMAGETYPE_JPEG:
                        $img = imagecreatefromjpeg($file);
                        imagejpeg( $img, NULL, 100 ); 
                        break;
                    case IMAGETYPE_GIF:
                        $img = imagecreatefromgif($file);
                        imagegif( $img ); 
                        break;
                    case IMAGETYPE_PNG:
                        $img = imagecreatefrompng($file);
                        imagepng( $img, NULL, 100 ); 
                        break;
                }
                if(!$img) {
                }
                else {
                    imagedestroy( $img );
                }
                $headers[] = "Content-Type: $mime_type";
                if($name !== null && trim($name) !== '') {
                    //download - without it image will not be downloaded just displayed on broswer
                    if( (strlen($name)-strlen($img_ext)) !== strpos($name, $img_ext) ) {
                        $name .= $img_ext;
                    }
                    $headers[] = "Content-Disposition: attachment; filename=$name";
                }
                self::$instance->app->headers = $headers;
            }
        }
    }
650938
private function loadFile(string $file) : string
    {
        if (!file_exists($file)) {
            throw new \Exception($file . ' not found');
        }
        return (string)file_get_contents($file);
    }
639774
public function attachment(string $file, ?string $name = null)
  {
    $this->attachment[] = ['file' => $file, 'name' => $name];
    return $this;
  }
1313382
public HttpRequest form(String name, File... files) {
		if (1 == files.length) {
			final File file = files[0];
			return form(name, file, file.getName());
		}
		return form(name, new MultiFileResource(files));
	}
1129949
public function file( $name = '' )
	{
		if( is_array( $name ) ){
			return $this->file = array_merge( $this->file, $name );
		}
		$files = $this->file;
		if( !empty( $files ) ){
			if( $name == '' ){
				return $files;
			} else{
				return $files[$name];
			}
		}
		return null;
	}
1079770
public static function loadFromFile($name) {
        static $loader = null;
        if ($loader === null) {
            $loader = new ConfigurationLoader();
        }
        if (empty($name)) {
            return new Configuration('');
        } else {
            return $loader->loadConfig($name);
        }
    }
791006
protected function addPostAttributes(File $file) {
        $arrAddAttributes = $this->getAllowedPostedAttributes();
        $file->addAttributes($arrAddAttributes);
        return $file;
    }
796254
public function download(string $file, ?string $name = null, ?array $headers = [])
  {
    return Rest::download(self::url($file), $name, $headers);
  }
558924
public function setFiles($file, $name = null)
	{
		// Verifying if is array
		if (is_array($file)) {
			foreach ($file as $k => $v) {
				$this->setFiles($v,$k);
			}
		} else {
			$parray = &$this->files;
			
			if (file_exists($file)) {
				if (is_null($file)) {
					if (isset($parray[$name])) unset($parray[$name]);
				} else {
					if (is_null($name) || is_integer($name)) {
						$count = count($parray);
						$name = 'file_contents_' . $count;
					}
						
					$parray[$name] = $file;
				}
			} else {
				throw new RuntimeException('Invalid file, file not exists.');
			}	
		}
		
		return $this;
	}
875411
public function attachment($file, $name = null)
    {
        if (!is_null($name)) {
            $this->_attachments[] = ['name' => $key, 'file' => $value];
        } else {
            $this->_attachments[] = ['file' => $value];
        }

        return $this;
    }