Am trying to insert image into a database in my project but things ain't working as expected, Am not sure as to where am getting it wrong. i keep getting this error message from my alert template.
The image must be an image. The image must be a file of type: jpeg,png, jpg, gif, svg.
mean while the uploaded image is an image with Jpeg format. i need help
public function register(Request $request){
$this->validate($request, [
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$newStudent = new Student;
if($file = $request->hasFile('image')) {
$file = $request->file('image') ;
$fileName = $file->getClientOriginalName() ;
$destinationPath = public_path().'/uploads/' ;
$file->move($destinationPath,$fileName);
$newStudent->image = '/public/uploads/'.$fileName ;
}
$newStudent -> StudentID = $request -> input('StudentID');
$newStudent -> cLevel = $request -> input('cLevel');
$newStudent -> surName = $request -> input('surName');
$newStudent -> fName = $request -> input('fName');
$newStudent -> fEmail = $request -> input('fEmail');
$newStudent -> DoB = $request -> input('DoB');
$newStudent -> pAddress = $request -> input('pAddress');
$newStudent -> save();
return response()->json(['status' => 'Image Uploaded Successfully']);
}