i want to get image from laravel storage and display it in react js
<img src={getImage(item.path)} />
getImage function
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
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
return response()->file($file, $headers);