I'm trying to store a path in the database but the forward slash is prefixed with a backward one when I see it in mysql. How to fix this?
["\/cars\/1_f202007c859996f7abc6c1af694b7fe5.jpg","\/cars\/1_755f1bda2c7a0c965b31786695059e8c.jpg"]
This is the function:
foreach($images as $image){
$image = str_replace('data:image/jpg;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$unique_string = md5(microtime());
$imageName = $user_id.'_'.$unique_string.'.'.'jpg';
File::put(public_path('cars'). '/' . $imageName, base64_decode($image));
$array[] = '/cars/'.$imageName;
}
source https://stackoverflow.com/questions/77010214/the-forward-slash-is-prefixed-with-a-backward-one-in-string-laravel
No comments:
Post a Comment