Laravel File Storage: How to store (decoded) base64 image?
Just use put
to store the encoded contents:
Storage::put('file.jpg', $encoded_image);
All it's doing is wrapping file_put_contents
.
Then to read it back out:
$data = base64_decode(Storage::get('file.jpg'));
Which, you guess it, is wrapping file_get_contents
.
You can upload your base64 Image using laravel File Storage like this
$base64_image = $request->input('base64_image'); // your base64 encoded
@list($type, $file_data) = explode(';', $base64_image);
@list(, $file_data) = explode(',', $file_data);
$imageName = str_random(10).'.'.'png';
Storage::disk('local')->put($imageName, base64_decode($file_data));
Hope it will help you