Build an UploadedFile object using various file input types.

@param  mixed $file
@return Expstudio\LaraClip\File\UploadedFile
962770
public function make($file)
	{
		if ($file instanceof SymfonyUploadedFile) {
			return $this->createFromObject($file);
		}

		if (is_array($file)) {
			return $this->createFromArray($file);
		}

		if (substr($file, 0, 7) == "http://" || substr($file, 0, 8) == "https://") {
			return $this->createFromUrl($file);
		}

		return $this->createFromString($file);
	}
741922
protected function createFromArray($file)
	{
		$file = new SymfonyUploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);

		return $this->createFromObject($file);
	}
366031
protected function _uploadImage($file = null) {
		$this->_uploadError = 'Undefined Error';
		$this->_allowedTypes = [
			'jpg',
			'bmp',
			'jpeg',
			'gif',
			'png'];

		$image = $file['name'];
		$ext = mb_strtolower(extractPathInfo($image, 'ext'));

		if (empty($ext) || !in_array($ext, $this->_allowedTypes)) {
			$this->_uploadError = 'Invalid File Type';
			return false;
		}

		if (empty($this->request->data['name'])) {
			$this->_uploadError = 'No MimeTypeImage Name given';
			return false;
		}

		$fileName = $this->request->data['name'];

		if (!array_key_exists($ext, MimeTypeImagesTable::extensions()) || (!empty($this->request->data['ext']) && $this->request->data['ext'] !=
			$ext)) {
			# re-render
			$this->Flash->success(__('re-rendered'));

			/*
			if (!empty($this->request->data['ext'])) {
			$ext = $this->request->data['ext'];
			} elseif (array_key_exists($ext, MimeTypeImage::extensions()) {
			$ext = '';
			}
			*/

		}
		$this->request->data['ext'] = $ext;

		# save new extension

		if (is_uploaded_file($file['tmp_name']) && move_uploaded_file($file['tmp_name'], PATH_MIMETYPES . $fileName . '.' . $ext)) {
			//TODO resize?

			return true;
		}
		return false;
	}
690207
public static function create($file)
    {
        // Verify ZipArchive is installed
        $zipArchive = class_exists('ZipArchive');

        try {
            return self::makeZipArchiver($file, ! $zipArchive, true);
        } catch ( Exception $e ) {
            return self::makeZipArchiver($file, $zipArchive, true);
        }
    }
72351
public function upload($file)
    {
        if ($this->isSubmodule) {
            $file = $this->isSubmodule.'/'.$file;
        }

        $dir = explode('/', dirname($file));
        $path = '';
        $pathThatExists = null;
        $output = array();

        // Skip basedir or parent.
        if ($dir[0] != '.' and $dir[0] != '..') {
            // Iterate through directory pieces.
            for ($i = 0, $count = count($dir); $i < $count; $i++) {
                $path .= $dir[$i].'/';

                if (!isset($pathThatExists[$path])) {
                    $origin = $this->bridge->pwd();

                    // The directory doesn't exist.
                    if (! $this->bridge->exists($path)) {
                        // Attempt to create the directory.
                        $this->bridge->mkdir($path);
                        $output[] = "Created directoy '$path'.'";
                    }
                    // The directory exists.
                    else {
                        $this->bridge->cd($path);
                    }

                    $pathThatExists[$path] = true;
                    $this->bridge->cd($origin);
                }
            }
        }

        $uploaded = false;
        $attempts = 1;

        // Loop until $uploaded becomes a valid
        // resource.
        while (!$uploaded) {
            // Attempt to upload the file 10 times
            // and exit if it fails.
            if ($attempts == 10) {
                $output[] = "Tried to upload $file 10 times, and failed 10 times. Something is wrong, so I'm going to stop executing now.";
                return $output;
            }

            $data = file_get_contents($file);
            $uploaded = $this->bridge->put($data, $file);

            if (!$uploaded) {
                $attempts++;
            }
        }

        $output[] = "√ \033[0;37m{$file}\033[0m \033[0;32muploaded\033[0m";

        return $output;
    }
39100
public function addMaterial($type, $file)
    {
        return $this->authRet(function () use ($type, $file) {
            $http = $this->http([
                'method' => 'post',
                'dataType' => 'json',
                'url' => $this->baseUrl . 'cgi-bin/material/add_material?type=' . $type . '&access_token='
                    . $this->accessToken,
                'files' => [
                    'media' => $file,
                ],
            ]);
            return $http;
        });
    }
644719
public function file( $file = null )
	{
		if ( !is_null( $file ) )
		{
			return $this->_file = $file;
		}
		
		return $this->_file;
	}
21885
public function addFile($file)
    {
        if (is_string($file)) {
            $file = array($file);
        }

        if (is_array($file)) {
            foreach ($file as $name) {
                if (!isset($this->_files[$name]) && !empty($name)) {
                    $this->_files[$name] = $name;
                }
            }
        }

        return $this;
    }
546731
public function withFile($file)
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException('File: ' . $file . ' not exists.');
        }

        return $this->withFileStream(new Stream($file));
    }
818854
public function make($file)
    {
        if ($file instanceof SymfonyUploadedFile) {
            return $this->createFromObject($file);
        }

        if (is_array($file)) {
            if (isset($file['base64']) && isset($file['name'])) {
                return $this->createFromBase64($file['name'], $file['base64']);
            }
            else {
                return $this->createFromArray($file);
            }
        }

        if (array_key_exists('scheme', parse_url($file))) {
            return $this->createFromUrl($file);
        }

        return $this->createFromString($file);
    }
1090565
public static function loadFile($file)
    {
        $json = new Json();

        return self::create($json->decodeFile($file), $json);
    }
4215
public function upload(UploadedFile $file)
    {
        self::$generic_file->moveUploadedFile(new File($file,
            $file->getClientOriginalName()), null, $this);

        return $this;
    }
1287644
protected function ensureEloquentFile($file)
    {

        if (!$file instanceof EloquentFile) {
            throw new TypeException("File has to be EloquentFile not " . Type::of($file));
        }

        if ($this->urlMapper) {
            $file->setUrlMapper($this->urlMapper);
        }

        return $file;

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

        return call_user_func($this->uploadPath, $file);
    }
858180
public function build($file = null)
    {
        $prepared = preg_replace_callback('/%.*%/U', function ($m) {
            if ($m[0] === '%phpdoc%') {
                $string = '/**';
                foreach ($this->components as $name => $classes) {
                    $string .= PHP_EOL . ' * @property ' . implode('|', $classes) . ' $' . $name;
                }
                $string .= PHP_EOL . ' */';
                return $string;
            }
            return $m[0];
        }, $this->template);
        if ($file === null) {
            return $prepared;
        }
        return (bool)file_put_contents($file, $prepared);
    }
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));
  }
1221583
public function store(UploadedFile $file, array $attributes = [])
    {
        $type = $this->resolveType($file);

        return $this->submit($file, $type, $attributes);
    }