How to save a Decode bae64 image to Laravel 8?

Asked

Viewed 21 times

0

I am receiving a several images in Base64 format. I only receive the string. How do I decrypt and save on Laravel 8’s Torage? I’m doing it like this but it makes a mistake:

    $image1 = $data['lstItensOS'][1]['foto1a'];
    //return $image1;
    $decoded=base64_decode($image1);
    $data['image'] = $decoded->store("rfs/ordenslocal/{$numOs}/fotos");

Error:
"message": "Call to a Member Function store() on string", "Exception": "Error",

  • 1

    base64_decode is not a class that has methods ( store in case). Have a look at doc. https://laravel.com/docs/8.x/filesystem#file-uploads.

  • I understood the comment but still not understood how to solve. I would have an example?

  • 1

    https://gist.github.com/oliveiraxavier/90668c738c2766069a73804a3082a642 Here is a simple example. The files will be in Storage/app/images. Don’t forget to run php Artisan Storage:link. I didn’t create validation rules to check if the uploaded file is allowed. Check the documentation https://laravel.com/docs/8.x/validation#Rule-mimes or right here on Sopt

  • Okay. Settled Thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.