Php 家中没有图像显示
在laravel中,我必须使用php artisan storage:link链接存储,这样我可以显示图像,当用户发布带有图像的文章时,图像将显示出来。但是现在,这张照片没有出现。我该怎么修呢 下面是views/post/index.blade.php中的代码Php 家中没有图像显示,php,laravel,Php,Laravel,在laravel中,我必须使用php artisan storage:link链接存储,这样我可以显示图像,当用户发布带有图像的文章时,图像将显示出来。但是现在,这张照片没有出现。我该怎么修呢 下面是views/post/index.blade.php中的代码 <tbody> @foreach($posts as $post) <tr> <td>
<tbody>
@foreach($posts as $post)
<tr>
<td>
<img src="{{ asset($post->image) }}" alt="">
</td>
<td>
{{ $post->title }}
</td>
<td>
<a href=" {{ route('categories.edit', $post->category->id) }}">
{{ $post->category->name }}
</a>
</td>
如果你们看到我没有出现在这里的任何问题,就问我。非常感谢各位如果您正在使用Laravel Storage,建议您使用存储功能来存储、获取或删除媒体文件 使用以下命令执行此操作: 储存:
Storage::disk(config('filesystems.default'))->put($path, $file);
要获得:
Storage::disk(config('filesystems.default'))->url($file);
删除:
Storage::disk('local')->delete($path);
您的代码如下所示:
<tbody>
@foreach($posts as $post)
<tr>
<td>
<img src="{{ Storage::disk(config('filesystems.default'))->url($post->image) }}" alt="">
</td>
<td>
{{ $post->title }}
</td>
<td>
<a href=" {{ route('categories.edit', $post->category->id) }}">
{{ $post->category->name }}
</a>
</td>
注意:如果您使用的是本地存储,请不要忘记检查文件系统是否设置为“本地”
<tbody>
@foreach($posts as $post)
<tr>
<td>
<img src="{{ Storage::disk(config('filesystems.default'))->url($post->image) }}" alt="">
</td>
<td>
{{ $post->title }}
</td>
<td>
<a href=" {{ route('categories.edit', $post->category->id) }}">
{{ $post->category->name }}
</a>
</td>
public function store(CreatePostRequest $request)
{
// upload image omegalul
$image = Storage::disk(config('filesystems.default'))->put('posts', $request->image);