codemode's avatar

Using hasFile() on RegistrationController gives error

Hi,

I'm trying to add an image upload field on User's registration.

The RegistrationController's create function seems to take 'array' as an argument instead of 'request' Looks like :

protected function create(array $data)

So here, when i do :

 if($data->hasFile('profilepic'))

When the register.blade.php has a simple file input field :

<input type="file" class="form-control @error('profilepic') is-invalid @enderror" name="profilepic" >

It given an error :

Call to a member function hasFile() on array

How can i call hasFile() on this function... and why is the parameter array instead of request here?

Many thanks!

0 likes
8 replies
Snapey's avatar

where are you trying to put this code?

codemode's avatar

@KANE - No sorry that does not work for me. Already googled that result

siangboon's avatar

hasFile() not belong to array method and you defined the $data as array...

use the hasFile() with $request

1 like
codemode's avatar

@KANE - I was using $request instead of request() .. this does work. Thanks!

Please or to participate in this conversation.