How to decode base64 in laravel 5.3

本小妞迷上赌 提交于 2019-12-12 02:17:13

问题


i am working on an API for mobile application, from mobile end i'm getting the image in base64 format and inserting it in profile_image column in my database

in my web i want to display that image, so how do i decode it

<div class="card horizontal card-driver-details">
    <div class="card-image card-circular">
        <img src="{{ $driver->profile_image}} "> //i want to display here
    </div>
    <div class="card-stacked">
        <div class="card-content">
            <p><b>Name:</b>{{ $driver->first_name }} {{ $driver->last_name }}</p>
            <p><b>Phone:</b>{{ $driver->phone_number }}</p>
            <p><b>Address:</b>{{ $driver->addess_city_village }} {{ $driver->address_state }}</p>
        </div>
    </div>
</div>

thank you


回答1:


Try

base64_decode($driver->profile_image);



回答2:


Try this one.

{{ base64_decode($driver->profile_image) }}

This will decode the profile_image using base 64 and then print the results.




回答3:


Try this:

$image = base64_decode('base_64_image_string');
$fp = fopen('path_to_where_you_want_to_save_image','wb+');
fwrite($fp,$image);
fclose($fp);



回答4:


i tried with the following code but din't work

base64_decode($driver->profile_image);

then did some browsing about this then find out now all the updated browser support data:image/jpeg/png/gif/etc

so now i am able to display the image

$driver->profile_image


来源:https://stackoverflow.com/questions/41690241/how-to-decode-base64-in-laravel-5-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!