I upload a file
In my controller, I did this
$file = Input::file('file'); dd($file);
I see this
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
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.