Get uploaded file from path

@param array $from
@param array $files
@param string $path
@return UploadedFile
546897
protected static function loadPath($from, &$files=array(), $path='') {
		$fileName = ($path === '') ? $from['name'] : apath_get($from['name'], $path);
// 		debug('LoadPath('.$path.') - $fileName', $fileName);
		if( empty($fileName) ) { return $files; }
		if( is_array($fileName) ) {
			if( $path!=='' ) { $path .= '/'; }
			foreach( $fileName as $index => $fn ) {
				static::loadPath($from, $files, $path.$index);
			}
// 			debug('loadPath() Files if name is an array', $files);
			return $files;
		}
		apath_setp($files, $path, new static($fileName, apath_get($from, 'size/'.$path),
			apath_get($from, 'tmp_name/'.$path), apath_get($from, 'error/'.$path)));
// 		debug('loadPath() Files if value is set', $files);
		return $files;
// 		$files[]	= ;
	}
552337
protected function setUploadedFiles(array $files)
    {
        $validate = function ($files) use (&$validate) {
            foreach ($files as $item) {
                if (is_array($item)) {
                    $validate($item);
                    continue;
                }
                if (! $item instanceof UploadedFileInterface) {
                    throw new InvalidArgumentException(
                        'Invalid structure of uploaded files provided.'
                    );
                }
            }
        };
        $validate($files);
        $this->uploadedFiles = $files;

        return $this;
    }
333614
protected  function createManifest($path, $files)
    {
        $data = [ ];
        foreach ( $files as $file ) {
            $data[] = [
                'type'      => $file[ 'type' ],
                'name'      => $file[ 'entity' ][ 'name' ],
                'full_name' => $file[ 'entity' ][ 'full_name' ],
                'namespace' => $file[ 'entity' ][ 'namespace' ],
            ];
        }
        $this->fs->put($path, Util::exportArray($data));
        return $data;
    }
780934
public static function createFrom(self $from, $to = null)
    {
        $request = $to ?: new static;

        $files = $from->files->all();

        $files = is_array($files) ? array_filter($files) : $files;

        $request->initialize(
            $from->query->all(),
            $from->request->all(),
            $from->attributes->all(),
            $from->cookies->all(),
            $files,
            $from->server->all(),
            $from->getContent()
        );

        $request->headers->replace($from->headers->all());

        $request->setJson($from->json());

        if ($session = $from->getSession()) {
            $request->setLaravelSession($session);
        }

        $request->setUserResolver($from->getUserResolver());

        $request->setRouteResolver($from->getRouteResolver());

        return $request;
    }
567075
protected function upload($path, $contents, $opts = []) {
        $location = $this->applyPathPrefix($path);
        try {
            $tmpfile = tmpfile();
            fwrite($tmpfile, $contents);
            $localFile = $this->getStreamUri($tmpfile);

            $obj = $this->client->simpleUpload($localFile, $location, $opts);
            fclose($tmpfile);
            return $this->normalizeResponse($obj);
        } catch (DropboxClientException $e) {
            return false;
        }
    }
8639
public function importSql($path, $files = array('setup_structure.sql'))
    {
        $status = false;
        $fImport = null;
        if(file_exists($path)) {
            foreach($files as $file) {
                if(file_exists($path.$file)) {
                    $fImport = file_get_contents($path.$file);
                    $this->executeRawQuery($fImport);
                    $this->importTableName = array_merge($this->importTableName, $this->getSqlFileTables($path.$file));
                }
            }
        }

        return $status;
    }
446876
public function file($path, $data = [], $mergeData = [])
    {
        $data = array_merge($mergeData, $this->parseData($data));

        return $this->viewInstance($path, $path, $data);
    }
972449
public static function copy(string $from, string $to) {
		ref\file::path($from, true);
		if (! $from) {
			return false;
		}

		ref\file::path($to, false);
		if (! $to || ($from === $to)) {
			return false;
		}

		// Recurse directories.
		if (@\is_dir($from)) {
			ref\file::trailingslash($from);
			ref\file::trailingslash($to);

			if (! @\is_dir($to)) {
				$dir_chmod = (@\fileperms($from) & 0777 | 0755);
				if (! static::mkdir($to, $dir_chmod)) {
					return false;
				}
			}

			// Copy all files and directories within.
			if ($handle = @\opendir($from)) {
				while (false !== ($file = @\readdir($handle))) {
					// Ignore dots.
					if (('.' === $file) || ('..' === $file)) {
						continue;
					}

					// Recurse.
					static::copy("{$from}{$file}", "{$to}{$file}");
				}
				\closedir($handle);
			}

			return true;
		}
		// Let PHP handle it.
		elseif (@\is_file($from)) {
			$dir_from = \dirname($from);
			$dir_to = \dirname($to);

			// Make the TO directory if it doesn't exist.
			if (! @\is_dir($dir_to)) {
				$dir_chmod = (@\fileperms($dir_from) & 0777 | 0755);
				if (! static::mkdir($dir_to, $dir_chmod)) {
					return false;
				}
			}

			// Copy the file.
			if (! @\copy($from, $to)) {
				return false;
			}
			$file_chmod = (@\fileperms($from) & 0777 | 0644);
			@\chmod($to, $file_chmod);

			return true;
		}

		return false;
	}
1352217
public static function load(string $path = null, array $paths = []): self
    {
        if (null === $path) {
            $config = [];
        } else {
            if (false === (new Filesystem())->isAbsolutePath($path)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to load to be an absolute path, got "%s" '
                        .'instead',
                        $path
                    )
                );
            }

            if (false === file_exists($path)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to exists but the file "%s" could not be '
                        .'found',
                        $path
                    )
                );
            }

            if (false === is_file($path) && false === (is_link($path) && is_file(readlink($path)))) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected the path of the configuration file to be a file but "%s" appears to be a '
                        .'directory.',
                        $path
                    )
                );
            }

            $config = include $path;

            if (false === is_array($config)) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected configuration to be an array, found "%s" instead.',
                        gettype($config)
                    )
                );
            }
        }

        self::validateConfigKeys($config);

        $prefix = self::retrievePrefix($config);

        $whitelistedFiles = null === $path ? [] : self::retrieveWhitelistedFiles(dirname($path), $config);

        $patchers = self::retrievePatchers($config);

        array_unshift($patchers, new SymfonyPatcher());

        $whitelist = self::retrieveWhitelist($config);

        $finders = self::retrieveFinders($config);
        $filesFromPaths = self::retrieveFilesFromPaths($paths);
        $filesWithContents = self::retrieveFilesWithContents(chain($filesFromPaths, ...$finders));

        return new self($path, $prefix, $filesWithContents, $patchers, $whitelist, $whitelistedFiles);
    }
358075
protected function getFilesListing($path, array $params)
    {
        $files = $this->getFiles($path, $params);
        return $this->prepareFiles($files);
    }
1063239
public static function getFileList(string $path, array $exts = null) : array
    {
        $files = [];
        if (is_dir($path) && ($dh = opendir($path))) {
            while (($file = readdir($dh)) !== false) {
                if ($file === '.' || $file === '..' || $file === '.DS_Store') {
                    continue;
                } elseif (is_dir("{$path}/{$file}")) {
                    $files = array_merge($files, self::getFileList("{$path}/{$file}", $exts));
                } elseif (is_null($exts)) {
                    $files[] = "{$path}/{$file}";
                } elseif (in_array(pathinfo("{$path}/{$file}", PATHINFO_EXTENSION), $exts)) {
                    $files[] = "{$path}/{$file}";
                } else {
                    continue;
                }
            }
            closedir($dh);
        }
        return $files;
    }
76448
private function uploadMediaChunked($path, $parameters)
    {
        // Init
        $init = $this->http('POST', self::UPLOAD_HOST, $path, [
            'command' => 'INIT',
            'media_type' => $parameters['media_type'],
            'total_bytes' => filesize($parameters['media'])
        ]);
        // Append
        $segment_index = 0;
        $media = fopen($parameters['media'], 'rb');
        while (!feof($media))
        {
            $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
                'command' => 'APPEND',
                'media_id' => $init->media_id_string,
                'segment_index' => $segment_index++,
                'media_data' => base64_encode(fread($media, self::UPLOAD_CHUNK))
            ]);
        }
        fclose($media);
        // Finalize
        $finalize = $this->http('POST', self::UPLOAD_HOST, 'media/upload', [
            'command' => 'FINALIZE',
            'media_id' => $init->media_id_string
        ]);
        return $finalize;
    }
1231740
public static function fromPath($path, $as = '')
    {
        clearstatcache(false, $path);

        if (!file_exists($path)) {
            throw new FileInfoException("$path does not exist");
        }

        $stat = stat($path);
        $file = new FileInfo();

        $file->setPath($path);
        $file->setIsdir(is_dir($path));
        $file->setMode(fileperms($path));
        $file->setOwner(fileowner($path));
        $file->setGroup(filegroup($path));
        $file->setSize(filesize($path));
        $file->setUid($stat['uid']);
        $file->setGid($stat['gid']);
        $file->setMtime($stat['mtime']);

        if ($as) {
            $file->setPath($as);
        }

        return $file;
    }
1075353
protected function file(array $attributes, $path)
    {
        $filesystem = new Filesystem;

        $file = new UploadedFile(
            $path,
            last(explode('/', $path)),
            $filesystem->mimeType($path),
            $filesystem->size($path),
            null, // error
            true
        );

        if (count($attributes)) {
            return collect(array_merge(compact('file'), $attributes));
        }

        return $file;
    }
965290
public function handle(UploadedFile $file, $path = 'files')
    {
        $filesize = $file->getClientSize();
        $mimetype = $file->getClientMimeType();
        $extension = strtolower($file->getClientOriginalExtension());
        $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
        $filename = $fileName.'.'.$extension;
        list($width, $height) = getimagesize($file);

        $filecounter = 1;
        while (Storage::has($path.'/'.$filename)) {
            $filename = $fileName.'_'.$filecounter++.'.'.$extension;
        }
        $path = $file->storeAs($path, $filename);
        $type = Arr::get(config('file.types'), $extension, 'd');

        return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type');
    }
195278
public function getPhpFiles(array $paths): FileCollection
    {
        $this->files = new FileCollection;
        foreach ($paths as $path) {
            $this->getPhpFilesFromPath($path);
        }

        return $this->files;
    }
1047333
public function uploadMultiple($files, $handler, $path = null)
    {
        $return = array(
            'errors' => array(),
            'transferred' => array()
        );

        if (!gplcart_file_multi_upload($files)) {
            return $return;
        }

        foreach ($files as $key => $file) {

            $result = $this->upload($file, $handler, $path);

            if ($result === true) {
                $return['transferred'][$key] = $this->getTransferred(true);
            } else {
                $return['errors'][$key] = (string) $result;
            }
        }

        return $return;
    }