saadaan's avatar

Detecting if an image is uploaded

Hi,

I am trying to detect in the controller if the variable carrying the image upload has some content in it or not (means image is uploaded or not), so that I could trigger image saving code. Can someone mention how to do it? Is this code right? user_photo is the actual variable which should have the image coming from the blade, if image is selected in UPLOAD FILE dialogue.

                if($request->user_photo)
                {
			... #image saving code
                }

Let me know if there is a better way.

Thanks, Saad

0 likes
1 reply
tykus's avatar
tykus
Best Answer
Level 104

$request->hasFile('user_photo')

Please or to participate in this conversation.