I'm working on a Laravel 4 application and I wrote a method called show()
inside my controller that gets the id
from the route and makes an array of some elements from the database, these elements will be returned with an image.
I can return the image without the text using Response::make()
and a header, but if I bind it with a data it can't read the image.
I tried to do something like :
public function show($id){
$onlineAd = OnlineAds::where('id', $id)->get(array('title', 'short_description', 'full_description'));
$fileName = OnlineAds::find($id)->image;
$path = 'app/storage/uploads/mobile/' . $fileName;
return Response::json([
"data" => $onlineAd,
"Image"=> base64_encode(File::get($path))
]);
}
This returns the data perfectly, but the image returns as an unreadable text instead. Any suggestions?