Laravel 4 - public directory being treated as a route - image not showing

旧城冷巷雨未停 提交于 2019-12-12 22:45:20

问题


I have this problem with Laravel 4's view. The code in view.blade.php is:

{{ HTML::image("public/images/storage/$user_upload->image.jpg") }}

which yields

http://dev.local/public/images/storage/1_thy9WFfBw.jpg

That is the correct image location, yet as being accessed by the framework, it turns out to be not accessible (i.e. HttpNotFound exception thrown). See screenshot: http://imgur.com/kKLu30L

I think the framework somehow treats this URL as a route resource rather than a public asset.

Is there anyway I could work this out?


回答1:


Try this instead:

{{ HTML::image(asset('images/storage/' . $user_upload->image . '.jpg')) }}



回答2:


{{ HTML::image("images/storage/$val->user_upload".".jpg", $alt="not found") }} 

If you are not still getting remove the .".jpg" extension because you might be storing file with extension



来源:https://stackoverflow.com/questions/23355289/laravel-4-public-directory-being-treated-as-a-route-image-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!