I managed to send an image using File Response: https://laravel.com/docs/9.x/responses#file-responses
From the Controller:
public function get_image(Request $request) {
$pathToFile = '../storage/uploads/460s6DLmCnvoom90S7wfk.jpg';
return response()->file($pathToFile); }
But I need to return multiple images, but this doesn't work (In this example I use the same image just for the test):
public function get_images(Request $request)
{
$images = [];
$pathToFile = '../storage/uploads/460s6DLmCnvoom90S7wfk.jpg';
for ($i = 0; $i < 20; $i++) {
$images[] = response()->file($pathToFile);
}
return $images;
}
It only returns array of empty headers. I am using Fetch API (Or AJAX) to get the images