Ad

Strange Behaviour With Image Input In Laravel 5.1

- 1 answer

I have an issue with my current web project. I need to check if my request contains an input called image, so I just apply the normal method like so:

if($request->has('image'))
{
    ...
}

But for some reason, this is not working as shown below:

laravel

Can someone explain me why ?

Ad

Answer

I think you need to access uploaded files as,

 $request->hasFile('image');

then it should be

if($request->hasFile('image')) { ...

see this DOC

Ad
source: stackoverflow.com
Ad