I have created a symlink to my local storage "(php artisan storage:link)" then, I save images on my public folder like that
public function store(PostStoreRequest $request)
{
$validated = $request->validated();
if($request->hasFile('postImage')) {
$path = $request->file('postImage')->store('public/images');
$validated['postImage'] = $path;
}
$post = auth()->user()->posts()->create($validated);
$post->categories()->attach($request->category);
return redirect()->route('articulos.index');
}
the $path contains public/images/IdC24xVkoFZiJFWtyKQ2T1xBVrS0GGU3d2Z4NXgP.jpeg
for example, it stores the image on storage/app/public/images.
Then in blade I show the image like that:
<img class="card-custom-img-post" src="{{ asset('storage/'.$post->postImage) }}">
It generate this URL: http://localhost/project/public/storage/public/images/IdC24xVkoFZiJFWtyKQ2T1xBVrS0GGU3d2Z4NXgP.jpeg
But the correct one is:
http://localhost/project/public/storage/images/IdC24xVkoFZiJFWtyKQ2T1xBVrS0GGU3d2Z4NXgP.jpeg
Anyway to get the correct url without replacing or anything similar?