i want to get image from laravel storage and display it in react js
JavaScript
x
<img src={getImage(item.path)} />
getImage function
JavaScript
const getImage = (path) => {
const di = axios.get("http://localhost:8000/api/"+path)
.then(res => {
return res.data;
});
return URL.createObjectURL(new Blob([di]));
}
my laravel controller function
JavaScript
public function download($image)
{
$path = "mail/{$image}";
if(Storage::exists($path)){
$file = Storage::download($path);
return Response::make($file, 200);
}
}
that what i get
please help me to find solution i have this problem since week
Advertisement
Answer
You should return it like this
JavaScript
return response()->file($file, $headers);