Ошибка в показе картинки в laravel - PullRequest
0 голосов
/ 20 октября 2019

Я хочу сохранить изображение в базе данных и показать его пользователю, но получаю ошибку 404, это моя ошибка:

GET http://127.0.0.1:8000/Images/jgS4ITBpNmiKWEW6ex7oWzcNxmBxnZEvyNjokXxT.jpeg 404 (не найдено)

А это мой код:

 public function store(Request $request)
    {
        $new_file_data=[
            'small_explain'=>$request->input('small_explain'),
            'title'=>$request->input('title'),
            'paragraph_one'=>$request->input('paragraph_one'),
            'paragraph_two'=>$request->input('paragraph_two'),
            'paragraph_list'=>$request->input('paragraph_list'),
            'paragraph_three'=>$request->input('paragraph_three'),
            'important_body'=>$request->input('important_body'),
            'quote'=>$request->input('quote'),
            'author_quote'=>$request->input('author_quote'),
            'index_image' => $request->file('index_image')->store('Images'),
            'header_image' => $request->file('header_image')->store('Images'),
            'text_image' =>$request->file('text_image')->store('Images'),
        ];
        Article::create($new_file_data);
    }

welcome.blade.php

@foreach( $recentArticles as $article)
                    <div class="work-detail">
                        <a href="home-restaurant.html">
                            <img src="{{ $article->index_image }}" alt="">
                            <div class="work-info">
                                <div class="centrize">
                                    <div class="v-center">
                                        <h3>{{ $article->title }}</h3>
                                        <p> {{ $article->small_explain }} </p>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
@endforeach

1 Ответ

0 голосов
/ 20 октября 2019
   <img src="{{ $article->index_image }}" alt="">

изменить на

<img src="{{ asset('/your custom path/' .$article->index_image) }}" alt="">
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...