Storage folder problem with slashes (Windows local)
Hi
I have a problem that I do not know how to resolve. Running Wamp64 on windows. Image is stored in storage/app/uploads whatever...
However, this code:
{{ storage_path('app/').$post->image_path }}
gives me error as it cannot find image:
D:\wamp64\www\lounginator\storage\app/uploads/imagename.jpg
Image was added by ->store method to "uploads" dir so it made app/uploads dir and stored file there
of course it can't as slashes are mixed with backslashes. If I upload it to linux server, all works, of course.
How to overcome this? (to work both in my local and in host server)
@beli0135
<a href="/storage/app/uploads/imagename.jpg">image</a>
<a href="{{ url('storage/app/uploads/imagename.jpg') }}">image</a>
{{ url('public/storage/app/'.$post->image_path) }}
This worked, but I did have to put "public" in. Thank you.
Is there something more elegant?
public_path will also give me windows' path.
It should be
<img src="{{ asset("storage/{$post->image_path}") }}" alt="Image">
so withut public in the path.
Link looks good this time.
However, it doesn't want to display image. I guess it is another problem.
I think I am getting 404
this is absolute path:
(D:.....\my_project\storage\app\public\uploads
is there some permission to be added or?
@beli0135
the command php artisan storage:link is point the public Disk
http://your-domain/storage
equal to
D:.....\my_project\public\storage
and hard linked to
D:.....\my_project\storage\app\public
so if the image stored at D:.....\my_project\storage\app\public\uploads\test.jpg
the url is http://your-domain/storage/uploads/test.jpg
the URI part of the URL is /storage/uploads/test.jpg
I know what happened, had problem with PHP yesterday, I lost storage link and composer is not working properly.
Will fix this.
Thanks everyone, I learnt how to overcome the problem.
Please or to participate in this conversation.