Php 在WebHost中托管后缺少图像

Php 在WebHost中托管后缺少图像,php,laravel,hosting,crud,laravel-8,Php,Laravel,Hosting,Crud,Laravel 8,我有一个使用laravel的简单CRUD项目。在本地服务器上一切运行都很顺利,但是在我尝试在000webhosting上托管之后,我的项目上的所有图像都不会显示。。。也许它在url中 以下是托管后web的外观: 这是我的密码 1: 2: 3: @foreach($blogs???“”作为$blog) image}}“class=”card img top“alt=“{{$blog->image}}> {{$blog->title} {!!$blog->content!!}

我有一个使用laravel的简单CRUD项目。在本地服务器上一切运行都很顺利,但是在我尝试在000webhosting上托管之后,我的项目上的所有图像都不会显示。。。也许它在url中

以下是托管后web的外观:

这是我的密码 1:


2:


3:


@foreach($blogs???“”作为$blog)
image}}“class=”card img top“alt=“{{$blog->image}}>
{{$blog->title}
{!!$blog->content!!}
@csrf
@方法('DELETE')
@endforeach

当然,我已经运行了命令[php artisan storage:link]…并且结果正常运行…但是在托管一切更改后

这里的问题是您的图像文件无法公开访问,因此在laravel中,您希望运行
php artisan storage:link
,然后您可以访问您的图像。更多信息检查

好的,您是说您无法访问托管上的终端计划。 下面是一个编程解决方案,在routes/web.php中创建一个web路由:

Route::get('/link', function () {
    Artisan::call('storage:link');
});
然后使用web浏览器
yourdomain.com/link
访问该链接。 如果不起作用,请尝试查找
/home/public_html
中是否有默认存储文件夹并将其删除,然后重试

另一个解决方案:

Route::get('/link', function () {        
   $target = '/home/public_html/storage/app/public';
   $shortcut = '/home/public_html/public/storage';
   symlink($target, $shortcut);
});

对文件结构上的$target变量和$shortcut进行任何必要的更改。

您需要运行php artisan storage:link命令。当然,我已经运行了该命令…并且结果正常运行…但是在托管所有内容都发生了更改之后,请通过终端在托管服务器上运行该命令。但在免费托管中无法运行该命令访问SSH:(…任何解决方案?当然,我已经运行了命令…并且结果正常运行…但是在托管所有内容之后,我尝试
Route::get('/link',function(){Artisan::call('storage:link');});
这个结果
ParseError语法错误,意外')“
这是一个语法错误,请跟踪文件和行中出现的错误。您还有一个“')”符号。查找并删除它。该错误与上述代码本身无关。@rahman022
<div class="row">
        @foreach ($blogs ?? '' as $blog)
            <div class="col-lg-4 col-md-6 col-sm-12">
                <div class="card my-2 shadow-sm">
                    <img src="{{ Storage::url('public/blogs/').$blog->image }}" class="card-img-top" alt="{{ $blog->image }}">
                    <div class="card-body">
                        <h5 class="card-title">{{ $blog->title }}</h5>
                        {!! $blog->content !!}
                        <form class="form-inline" onsubmit="return confirm('Apakah Anda Yakin ?');" action="{{ route('blog.destroy', $blog->id) }}" method="POST">
                            <a href="{{ route('blog.edit', $blog->id) }}" class="btn my-1 btn-block btn-primary"><i class="fas fa-edit"></i></a>
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn my-1 btn-block btn-danger"><i class="fas fa-trash"></i></button>
                        </form>
                    </div>
                </div>
            </div>
        @endforeach
    </div>
Route::get('/link', function () {
    Artisan::call('storage:link');
});
Route::get('/link', function () {        
   $target = '/home/public_html/storage/app/public';
   $shortcut = '/home/public_html/public/storage';
   symlink($target, $shortcut);
});