May 15, 2019
0
Level 5
Upload image base_64 format issue
I'm trying to upload an image using Intervention Image package but I'm always getting the following error
** Intervention\Image\Exception\NotReadableException: Unable to init from given binary data. **
This is my upload code
this is the image string : data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD…d2dFZfOcMOByDWtESycgDHHSsa0xtCgcetagiWRQefSrMWf/Z"
if($request->get('image'))
{
$image = $request->get('image');
$name = time().'.' . explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
$base=base64_decode($image);
\Image::make($base)->save(public_path('images/').$name);
}
return response()->json(['status'=>200,'img'=>$request->get('image')]);
Any help ?
Please or to participate in this conversation.