Laravel 5.5 - 如何链接blade.php以查找公用文件夹中的图像

时间:2018-01-25 22:03:58

标签: php laravel-5.5

我用HTML创建了一个包含大量图片的网页。现在我需要在我的laravel项目中使用该页面,我添加了CSS并遵守了它的优点。问题在于图像,如何链接我的blade.php以在public / images文件夹中查找图像。

我做了一些搜索,它显示了添加

src="images/background.jpg"

而不是

cordova run android
ANDROID_HOME=/Users/macbookpro/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
(node:58469) UnhandledPromiseRejectionWarning: Error: spawn EACCES
at _errnoException (util.js:1003:13)
at ChildProcess.spawn (internal/child_process.js:340:11)
at Object.exports.spawn (child_process.js:499:9)
at Object.exports.spawn (/Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
at GradleBuilder.runGradleWrapper (/Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/lib/builders/GradleBuilder.js:78:27)
at /Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/lib/builders/GradleBuilder.js:177:21
at _fulfilled (/Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/node_modules/q/q.js:854:54)
at self.promiseDispatch.done (/Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/node_modules/q/q.js:883:30)
at Promise.promise.promiseDispatch (/Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/node_modules/q/q.js:816:13)
at /Users/macbookpro/desktop/mobile/ionic/2018/vv/platforms/android/cordova/node_modules/q/q.js:570:49
(node:58469) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:58469) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[OK] Your app has been deployed.
     Did you know you can live-reload changes from your app with --livereload?

但是我的页面有大量的图像,有没有办法可以链接blade.php来查找公共文件夹中的图像,就像我们为CSS编译一样?

1 个答案:

答案 0 :(得分:0)

Laravel拥有文件存储系统。 https://laravel.com/docs/5.5/filesystem

在控制器中,您可以读取特定目录中的文件列表,并且您有文件列表数组。之后,您可以将此数组列表发送到查看文件。

在视图文件中,您使用foreach循环所有文件并提供链接。

我建议将此文件放在存储文件夹中。文件清楚地解释了这一点。