I am new in larval development, I am unable to upload image in local folder and I am getting error getClientOriginalExtension() on null. Even I have added code enctype="multipart/form-data" in my form, but still am getting the error. Can anyone give suggestion how to resolve this issue. I have given below my code. MyBlade file
****MyBlade file****
<form action="" method="POST" enctype="multipart/form-data" accept-charset="utf-8" >
@csrf
<div class="form-group row">
<label for="uname" class="col-md-4 col-form-label text-md-right">User Name</label>
<div class="col-md-6">
<input type="text" id="username" class="form-control" name="username" required />
@if ($errors->has('username'))
<span class="text-danger"></span>
@endif
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">Profile Picture</label>
<div class="col-md-6">
<input id="image" type="file" class="form-control" name="image">
</div>
</div>
My Controller File
if ($files = $request->hasfile('image')) {
$destinationPath = 'public/image/'; // upload path
$profileImage = date('YmdHis') . "." . $files->getClientOriginalExtension();
$files->move($destinationPath, $profileImage);
}
else{
return $request;
}
I am getting err:Call to a member function getClientOriginalExtension() on bool
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3HsDdqG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire