Reputation: 1334
I want to access pic in $request which is instance of UploadedFile class but when I use
$request->pic;
it returns nothing...
this is my dd($request->all()) result
array:4 [
"title" => "blah blah
"desc" => "some text"
"respawn" => "mail"
"pic" => UploadedFile {#27
-test: false
-originalName: "hamayesh-hesabdari2.jpg"
-mimeType: "image/jpeg"
-size: 160295
-error: 0
}
]
how can I access it?
Upvotes: 2
Views: 71
Reputation: 163748
Use file()
method to get the file:
$request->file('pic')
And hasFile()
method to check if file exists:
if ($request->hasFile('pic'))
Upvotes: 3