Load an image from a form file input

@param bool $name File input name attribute

@return void -
320830
public function getFromInput($name = false)
    {
        if ($name) {
            $this->img       = $_FILES[$name];
            $this->handle    = new Upload($this->img);
            $this->_new_name = $this->s3->sanitizeFilename(uniqid("", true) . $this->handle->file_src_name);
        }
    }
1339899
public function upload($name)
    {
        $instance = $this->_getInstance($name);
        require_once Plugin::classPath('Field') . 'Lib/class.upload.php';
        $uploader = new \upload($this->request->data['Filedata']);

        if (!empty($instance->settings['extensions'])) {
            $exts = explode(',', $instance->settings['extensions']);
            $exts = array_map('trim', $exts);
            $exts = array_map('strtolower', $exts);

            if (!in_array(strtolower($uploader->file_src_name_ext), $exts)) {
                $this->_error(__d('field', 'Invalid file extension.'), 501);
            }
        }

        $response = '';
        $uploader->file_overwrite = false;
        $folder = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/");
        $url = normalizePath("/files/{$instance->settings['upload_folder']}/", '/');

        $uploader->process($folder);
        if ($uploader->processed) {
            $response = json_encode([
                'file_url' => Router::url($url . $uploader->file_dst_name, true),
                'file_size' => FileToolbox::bytesToSize($uploader->file_src_size),
                'file_name' => $uploader->file_dst_name,
                'mime_icon' => FileToolbox::fileIcon($uploader->file_src_mime),
            ]);
        } else {
            $this->_error(__d('field', 'File upload error, details: {0}', $uploader->error), 502);
        }

        $this->viewBuilder()->layout('ajax');
        $this->title(__d('field', 'Upload File'));
        $this->set(compact('response'));
    }
1093489
protected function loadPlugin($name, $file)
    {
        require_once $file;
        $className = sprintf('Zicht\Tool\Plugin\%s\Plugin', ucfirst(basename($name)));
        $class     = new \ReflectionClass($className);
        if (!$class->implementsInterface('Zicht\Tool\PluginInterface')) {
            throw new \UnexpectedValueException("The class $className is not a 'Zicht\\Tool\\PluginInterface'");
        }
        $this->plugins[$name] = $class->newInstance();
    }
133254
protected function loadFile($name) {
		
		// get pattern data
		list($partialName,$styleModifier,$parameters) = $this->patternUtil->getPartialInfo($name);
		
		// get the real file path for the pattern
		$fileName = $this->baseDir."/".$this->patternUtil->getFileName($partialName,$this->extension);
		
		// throw error if path is not found
		if (!file_exists($fileName)) {
			throw new \Mustache_Exception_UnknownTemplateException($fileName);
		}
		
		// get the file data
		$fileData = file_get_contents($fileName);
		
		// if the pattern name had a style modifier find & replace it
		if (count($styleModifier) > 0) {
			$fileData = $this->patternUtil->findReplaceParameters($fileData, $styleModifier);
		}
		
		// if the pattern name had parameters find & replace them
		if (count($parameters) > 0) {
			$fileData = $this->patternUtil->findReplaceParameters($fileData, $parameters);
		}
		
		return $fileData;
		
	}
88986
protected function load($filename)
    {
        $success = false;

        if (file_exists($filename)) {
            /** @noinspection PhpIncludeInspection */
            require $filename;
            $success = true;
        }

        return $success;
    }
1102486
protected function load($name)
    {
        if (!$this->initialized) {
            $this->initialize();
        }

        if (isset($this->cache[$name])) {
            return $this->cache[$name];
        }

        $cache = $this->cachePath ? sprintf('%s/%s.cache', $this->cachePath, sha1($name)) : false;

        if (!$cache) {

            $storage = new StringStorage($this->compile($this->loader->getSource($name), $name));

        } else {

            if (!is_file($cache) || !$this->isTemplateFresh($name, filemtime($cache))) {
                $this->writeCacheFile($cache, $this->compile($this->loader->getSource($name), $name));
            }

            $storage = new FileStorage($cache);
        }

        return $this->cache[$name] = $storage;
    }
999585
public function loadTemplate($name)
    {
        $template = new Template();
        $template->app = $this;

        if (in_array($name[0], ['.', '/', '\\']) || strpos($name, ':\\') !== false) {
            return $template->load($name);
        } else {
            $dir = is_array($this->template_dir) ? $this->template_dir : [$this->template_dir];
            foreach ($dir as $td) {
                if ($t = $template->tryLoad($td.'/'.$name)) {
                    return $t;
                }
            }
        }

        throw new Exception(['Can not find template file', 'name'=>$name, 'template_dir'=>$this->template_dir]);
    }
980401
public function loadData($name) {

        $file = sprintf('%s/../Resources/fixtures/%s.yml', __DIR__ , $name);
        if(!file_exists($file)) {
            throw new \Exception(sprintf('fixtures file "%s" not found for name "%s"', $file, $name));
        }

        $data = Yaml::parse($file);

        $items = [];
        foreach ($data as $args) {
            $item = $this->create($args);
            $this->manager->persist($item);
            $items[] = $item;
        }

        $this->manager->flush();
    }
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;
            }
        }
    }
726884
private function loadHelper(string $name): void
    {
        $class = static::class;

        // Somebody forgot to call `addHelperPath`
        if (!isset(static::$helpersPath[$class])) {
            throw new CommonException("Helper path not found for class `$class`");
        }

        // Try to find helper file
        foreach (static::$helpersPath[$class] as $path) {
            if ($helperPath = realpath($path . '/' . ucfirst($name) . '.php')) {
                $this->addHelper($name, $helperPath);
                return;
            }
        }

        throw new CommonException("Helper `$name` not found for class `$class`");
    }
1231995
public function load($name) {
		
		if (!isset($this->templates[$name])) {
			try {
				$this->templates[$name] = $this->loadFile($name);
			} catch (Exception $e) {
				print "The partial, ".$name.", wasn't found so a pattern failed to build.\n";
			}
		}
		
		return (isset($this->templates[$name])) ? $this->templates[$name] : false;
		
	}
138861
public function load($name)
    {
        $stall = $this->redis->get("bstall_{$name}");

        if(is_null($stall)) {
            $this->clean();
            $this->save($name);
        } else {
            $canvas = unserialize($stall);
            $this->canvas = $canvas;
        }
    }
133601
public function isFile(String $name) : Bool
    {
        $file = Method::files($name);

        if( is_array($file) )
        {
            return (bool) $file[0];
        }

        return (bool) Method::files($name);
    }
304881
protected function loadData(string $name)
	{
		if (isset($this->data[$name])) return $this->data[$name];
		else return null;
	}
1272524
protected function load_if_needed($name)
  {
    // Reload when retrieving dirty data
    if ($this->_loaded && empty($this->_operations) && !empty($this->_dirty[$name]))
    {
      return $this->load();
    }

    // Lazy loading!
    else if ($this->_loaded === NULL && isset($this->_object['_id']) && !isset($this->_changed['_id']) && $name != '_id')
    {
      return $this->load();
    }
    return FALSE;
  }
2162
public function setImagePrettyName($name)
    {
        $this->set('prettyname', $name);
        if ($this->image) {
            $this->image->setPrettyName($name);
        }
    }
482966
protected function validateFileType($name)
    {
        $extension = strtolower(File::extension($name));

        $allowedFileTypes = FileDefinitions::get('defaultExtensions');

        if (!in_array($extension, $allowedFileTypes)) {
            return false;
        }

        return true;
    }