首页 > 解决方案 > Laravel 在根文件夹外显示图像

问题描述

我在本地机器上运行一个 Laravel 网站。我的 laravel 在文件夹中:/Username/bigproject/laravel-project

在我的 Laravel 应用程序的视图中,有一些标签应该显示 /Username/bigproject/images 文件夹中的文件(所以它在 laravel 根文件夹之外)。如何在 src 中形成 url 以便显示这些图像?

<img src="/Username/bigproject/images/image1.jpg">不工作,当然。

我玩过https://laravel.com/docs/5.4/filesystem的磁盘存储,但没有结果。

PS。该项目实际上仅供本地使用。

标签: phplaravelimage

解决方案


As the web server cant access files out side of its root, you can create a symbolic link so the files can be in two locations at once.

ln -s /Username/bigproject/images /Username/bigproject/larave-project/public 

thus allowing the web-server (ultimately the browser) to use the access the files with <img src="/catPic.jpg">


推荐阅读