I upload a file
In my controller, I did this
JavaScript
x
$file = Input::file('file');
dd($file);
I see this
JavaScript
IlluminateHttpUploadedFile {#1388 ▼
-test: false
-originalName: "config-nsd-got.yaml"
-mimeType: "application/x-yaml"
-error: 0
#hashName: null
path: "/private/var/tmp"
filename: "phpb73hcy"
basename: "phpb73hcy"
pathname: "/private/var/tmp/phpb73hcy" <<<<<<---------- I WANT TO ACCESS THIS
extension: ""
realPath: false
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
I want to pathname: "/private/var/tmp/phpb73hcy"
,
I’ve tried
JavaScript
dd($file->pathname());
dd($file["pathname"]);
I just want this /private/var/tmp/phpb73hcy
Any hints for me ?
Advertisement
Answer
Use $this->getPathname()
.
The Laravel UploadedFile
class extends the Symfony UploadedFile
class, which extends the Symfony File
class, which extends the PHP SplFileInfo
class. The latter has the getPathname()
method.