I have been struggling to upload an image using a simple form. Every time I upload the file, it says there is no file, as per the functionality I've set up in the controller. Here is the code so far:
The blade form:
<div class="text-align-center">
{{Form::open(['url' => 'profile', 'files' => true]) }}
{{Form::file('avatar')}}
{{Form::submit('Update',['class' => 'pull-left btn btn-sm btn-primary']) }}
{{Form::close() }}
</div>
The routes file:
Route::get('profile', 'UserController@profile');
Route::post('profile', 'UserController@avatar');
Route::resource('users','UserController');
The UserController
:
public function profile(){
return view('profile', array('user' => Auth::user()));
}
public function avatar(Request $request){
if($request->hasFile('avatar')){
var_dump($request);
}
else
die('there is no file here!');
}
The User
model:
protected $fillable = [
'username', 'email', 'avatar'
];
My php.ini
has maximum file size limits of 8M, the file I'm trying to upload is only a few KB.