Linton Samuel Dawson Linton Samuel Dawson -4 years ago 91
jQuery Question

UploadedFile in $request

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?

Answer Source

Use file() method to get the file:

$request->file('pic')

And hasFile() method to check if file exists:

if ($request->hasFile('pic'))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download