I'm trying to save image using Laravel
Image is saved as tmp file in database, why so?
the image saved as C:\xampp\tmp\phpA3EB.tmp in the database
how can I fix this?
in the controller:
public function update(Request $request, Bank $bank)
{
if ( isset($request->photo) && $request->photo ) {
$request['image'] = UploadImage($request->file('photo'), 'bank', '/banks');
@unlink(public_path('/uploads/banks/') . $bank->image);
}
$updated = $bank->update($request->all());
$bank->updateTranslations([
'name' => $request->get('name_en'),
]);
return $updated ?
redirect()->route('banks.index')->with('success', trans('messages.updateTrue')) :
redirect()->back()->with('warning', trans('messages.updateFalse'));
}
function UploadImage($inputRequest, $prefix, $folderNam)
{
$imageName = $prefix.'_'.time().'.'.$inputRequest->getClientOriginalExtension();
$destinationPath = public_path('/uploads/'.$folderNam);
$inputRequest->move($destinationPath, $imageName);
return $imageName ? $imageName : false;
}