如何使用storage_path()在laravel 4中查看图像 [英] How to use storage_path() to view an image in laravel 4

查看:773
本文介绍了如何使用storage_path()在laravel 4中查看图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用storage_path()来存储上传的图像,但是当我使用它时,它在页面上指向错误.

I'm using storage_path() for storing uploaded images, but when I use it is pointing wrong on my page.

我像这样使用它{{ $data->thumbnail }},其中$data来自数据库,缩略图作为使用storage_path

I use it like this {{ $data->thumbnail }} where $data came from the database and thumbnail comes as the string which used storage_path

推荐答案

让我们看一下默认的L4应用程序结构:

Let us take a look at the default L4 application structure:

app//包含受限制的服务器端应用程序数据

app // contains restricted server-side application data

app/storage//L4和自定义函数用于存储数据(即日志文件等)的可写目录

app/storage // a writeable directory used by L4 and custom functions to store data ( i.e. log files, ... )

public//此目录可供客户访问

public // this directory is accessible for clients

如果我是你,我将文件直接上传到公共目录:

If I were you, I would upload the file to the public directory directly:

  1. 将图像存储在此处:public_path(). 'img/filename.jpg'
  2. 在数据库中保存"img/filename.jpg"
  3. 使用url('img/filename.jpg')=> http生成图像URL ://www.your-domain.com/img/filename.jpg

希望这会有所帮助.

这篇关于如何使用storage_path()在laravel 4中查看图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆