Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 8,从数据库中重新查看的图像url不返回图像_Laravel - Fatal编程技术网

Laravel 8,从数据库中重新查看的图像url不返回图像

Laravel 8,从数据库中重新查看的图像url不返回图像,laravel,Laravel,我为这个问题挣扎了好几个小时。我的问题是,我的数据库中保存了一个图像url,当我检索它时,我试图在index.blade.php中显示它。奇怪的是,我在一个旧项目中使用了相同的代码,它工作了,但我打开了旧项目,它也不再工作了。我已经做了php artisan storage:link,从我看到的链接是正确的,但图像显示为断开,我查找了各种解决方案,但所有这些都导致了死胡同,因为url只是不想显示图像。图像url保存在此表单中 My index.blade.php tbody <tbod

我为这个问题挣扎了好几个小时。我的问题是,我的数据库中保存了一个图像url,当我检索它时,我试图在index.blade.php中显示它。奇怪的是,我在一个旧项目中使用了相同的代码,它工作了,但我打开了旧项目,它也不再工作了。我已经做了
php artisan storage:link
,从我看到的链接是正确的,但图像显示为断开,我查找了各种解决方案,但所有这些都导致了死胡同,因为url只是不想显示图像。图像url保存在此表单中

My index.blade.php tbody

  <tbody>
    @foreach($companies as $company)
        <tr>
            <td scope="row">{{$company->id}}</td>
            <td>{{$company->name}}</td>
            <td>{{$company->email}}</td>
            <td><img class="class='img-fluid rounded mb-3 mb-lg-0 ml-md-0" src="{{$company->logo}}"></td>
            <td>{{$company->url}}</td>
            <td>
                <a href="{{route('company.edit', $company->id)}}" class="float-left">
                    <button type="button"
                            class="btn btn-primary mr-2">{{__('Edit')}}</button>
                </a>
                <form action="{{route('company.delete',$company->id)}}" method="POST"
                      class="float-left">
                    {{method_field('DELETE')}}
                    @csrf
                    <button type="submit"
                            class="btn btn-danger btn-sn">{{__('Delete')}}</button>
                </form>
            </td>
        </tr>
    @endforeach
    </tbody>
如何存储我的图像url

   public function store(Request $request): RedirectResponse
    {
    $request->validate([
        'name' => 'required',
        'email' => '',
        'logo' => 'dimensions:min_width:100,min_height:100',
        'url' => ''
    ]);
    $parameters = $request->all();
    if ($request->logo !== null) {
        $image = $request->logo->store('public');
        $parameters['logo'] = URL::to('/') . '/storage/' . $image;
    }
    $this->company->create($parameters);

    return redirect()->route('company.index');
}

我不确定这是否足够,但我想这些是主要部分。

默认情况下
php artisan storage:link
使用
存储/app/public
创建一个符号链接,因此将图像从
存储/public
移动到
存储/app/public
。然后您可以通过
http://127.0.0.1:8000/storage/vsX9ihmRknGWLXtNRmxgCXV3ckqhlFoBlyuMoejB.png

默认情况下
php artisan storage:link
使用
storage/app/public
创建一个符号链接,以便将图像从
storage/public
移动到
storage/app/public
。然后您可以通过
http://127.0.0.1:8000/storage/vsX9ihmRknGWLXtNRmxgCXV3ckqhlFoBlyuMoejB.png
谢谢你,你是救命恩人
   public function store(Request $request): RedirectResponse
    {
    $request->validate([
        'name' => 'required',
        'email' => '',
        'logo' => 'dimensions:min_width:100,min_height:100',
        'url' => ''
    ]);
    $parameters = $request->all();
    if ($request->logo !== null) {
        $image = $request->logo->store('public');
        $parameters['logo'] = URL::to('/') . '/storage/' . $image;
    }
    $this->company->create($parameters);

    return redirect()->route('company.index');
}