Question: How can I get File Object from absolute Path?

The object is like when I get from `$request->file('fileInput')`.

So i can use method like `$file->getClientOriginalName()` or `$file->getClientOriginalExtension()` or something like that.

I can only find the way to get the File Object using `File::allFiles($absoluteFolderPath)` and loop through it to find the file that have the filename that i looking for.

But is there something simpler?

Answer: 
**Request::file()** method returns objects of the class **UploadedFile**. You can create such object yourself, but it kind of kills the purpose of the class, as it's supposed to be used for, well, uploaded files :) You should use the File class instead that is the parent class of the UploadedFile. You can create such object this way:

```
$uploadedFile = new \Symfony\Component\HttpFoundation\File\File($filePath);

```

If you instantiate the file this way, you won't have access to **getClient...()** methods as they are used to return the information about the file that it got from the client browser.

If you want to get some additional info about the file you can use **getMimeType()** or **getExtension()** methods.
For this you can use 

```
Symfony\Component\HttpFoundation\File\UploadedFile

```

But please be aware that you can not use the `move()` function, because on move() it will check, if this file has been uploaded via HTTP.

If you want to bypass this mechanism, you need to do it on your own.

In my application i did it the following way:

```
public static function uploadFile($file, $client, $fromServer = false){
    //... unimportant stuff
    if($file->isValid()){
        $upload_success = $file->move($media->path, $media->original_name);
    } else if($fromServer){
        rename($file->getPathname(), $media->path . $media->original_name);
        $upload_success = true;
    } else {
        $upload_success = false;
    }

    if(!$upload_success){
        throw new \Exception("Upload failed");
    }

```

Its also an issue for testing, which you will find here: <https://laracasts.com/discuss/channels/testing/file-upload-unkown-error-with-phpunit>

Currently I didnt find an optimal (global) solution to this. But i guess its good the way it is, since you dont want anybody to move files on your server, that are not uploaded via HTTP.