php - Why does the image name change between Mysql and Laravel
I have a problem which is that the image name in Mysql post featured field is : "/uploads/posts/img1.jpg" .but when I retrieve the image name from Laravel with the following statement: $image_path = $post->featured , I get a full url "http://127.0.0.1:8000/uploads/posts/img1.jpg" . I need the result to be in the database format to be able to delete the image.
Please help.
Answer
Solution:
When you just echo $image_path, what did you get?
If you use asset($image_path)
, it will put the full URL.
If you only want to get the path, use {{ $image_path }}
or directly {{ $post->featured }}