I want to upload images with laravel:I created the field in mysql:
imagepath varchar 250
Created the form:
<form method="post" id="formId" action="/ticket" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group ">...other fields
<div class="form-group">
<input type="file" class="form-control-file" name="imageFile" id="imageFile" aria-describedby="fileHelp">
</div>
In my controller:
public function store(Request $request)
{
$fileName = request()->imageFile->getClientOriginalExtension();
dd($fileName);//echos ".jpg"
$tickes = Users::create(['imagePath' => $fileName]);
}
However my db is always null!I want to store it in my public/storage folder in Laravel. Please help!
imagePath
to$fillable
inUser
model – Alihossein shahabi