mardi 6 février 2018

Images in sorage/images are in base64

I'm storing images in database and is working perfectly, but in storage/images are not showing as a images but i think in base64- R{b�W��x. Can anyone help me?

public function uploadImage($image_64){
    $file_extension = 'jpg';
    $actual_name = "productImage";
    $file_name = '';
    $original_name = $actual_name;
    $i = 1;
    $hash = md5(substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(1,10)));
    $file_name = $actual_name.'_'.$hash.'.jpg';

    @list($type, $image_64) = explode(';', $image_64);
    @list(, $image_64) = explode(',', $image_64);
    if($image_64!=""){ // storing image in storage/app/public Folder
        if(Storage::disk('public')->put('images/'.$file_name,base64_decode($image_64))){
                return '/images/'.$file_name;
        }else{
           return "";
        }

    }
}

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire