CONTROLLER public function store(Request $request){ $data = new Profile; for UPDATE if($request->hasfile('image')) { $destination = 'images/users/'.$data->image; if(File::exists($destination)){ File::delete($destination); } } $data->image = $this->storeBase64($request->image_base64); $data->save(); return back()->with('success', 'Image uploaded successfully.'); } private function storeBase64($imageBase64){ list($type, $imageBase64) = explode(';', $imageBase64); list(, $imageBase64) = explode(',', $imageBase64); $imageBase64 = base64_decode($imageBase64); $imageName= time().'.png'; $path = public_path() . "/images/users/" . $imageName; file_put_contents($path, $imageBase64); return $imageName; } BLADE CSS --------------------
BODY --------------------
@csrf
Image*
Submit
JS --------------------