I have fuction for upload image in base64:
public function upload(UploadImageRequest $request)
{
$data = (\Request::input('image'));
$decode = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
$info = @getimagesizefromstring($decode);
$extn = image_type_to_extension($info[2]);
if ($extn ==".png"){
$fullName = md5(time().uniqid()).$extn;
Storage::disk('public')->put('images/',$fullName, $decode);
$image = Image::make();
$image->url = Storage::url($fullName);
$image->saveOrFail();
return Response::json($image, ResponseHttp::HTTP_CREATED);
}
else {dd(1);}
}
I try to save my image to public/image/ directory, but failed.
ERROR:
(1/1) ErrorException
file_put_contents(/home/artem/PhpstormProjects/thefeedfeed-api/storage/app/public/images): failed to open stream: Is a directory
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire