0

I'm trying to upload an image in laravel and I'm using store method to save it in storage.

$path = $request->file('avatar')->store('public/avatar');

It's working fine and save the file into storage/app/public/avatar/ directory and its path will be somethin like this:

public/avatar/o4C4pTNuot8dDmAjpATPn5ZJWMkbfhdKJGF5PEmw.jpg

And that's ok! but I have a problem with retrieving this image! when I try this address:

domain.local/public/avatar/o4C4pTNuot8dDmAjpATPn5ZJWMkbfhdKJGF5PEmw.jpg

it shows a 404 not found page.

Anyway! I know that, if I change public to storage in address, it will show me the image.

Is it normal? I know something is not ok, but I don't know what and why!

p.s: I used php artisan storage:link and created symlink before, so my address is accessible.

Ashkan
  • 47
  • 1
  • 8
  • have you tried tag ? – It's VIN May 25 '21 at 09:12
  • if you have symlinked the storage path to public path, you can access the file from the public path directly. and if you serve your project without `public` in the url, then you have to omit the public part from the url to access the file. `domain.local/avatar/o4C4pTNuot8dDmAjpATPn5ZJWMkbfhdKJGF5PEmw.jpg` – zahid hasan emon May 25 '21 at 09:53
  • @MR.VIN Yes. but it's not working. – Ashkan May 25 '21 at 12:40
  • @zahidhasanemon I already tested this one too! and gues what? not working :-\ I appreciate your time and your answer, anyway :) – Ashkan May 25 '21 at 12:55

0 Answers0