storage:链接在托管cPanel上不起作用 [英] storage:link not working on hosting cPanel

查看:93
本文介绍了storage:链接在托管cPanel上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我用php artisan storage:link创建了一个存储链接,并且在 localhost 上可以正常工作,但是,当我在共享主机上部署项目时,它不会显示任何图像.这是我的托管目录结构:

So, I've created a storage link with php artisan storage:link and it's working totally fine on localhost, However when I deploy my project on a shared hosting, it does not show any images. This is my hosting directory structure:

- home2/username
:   + other hosting folders
:   - MyLaravelWebSite
:   :   + other laravel folders
:   :   - storage
:   :   :   - app
:   :   :   :   - public
:   :   :   :   :   -images
:   :   :   :   :   :   * some-image.jpg
:   :   :   :   * gitignore
:   :   :   + framework
:   :   :   + logs
:   - public_html
:   :   + assets
:   :   + storage // symlink
:   :   * index.php

图像上传完全正常,但是每当我尝试显示它们时,它们都不会显示,而它们在localhost上则显示完全正常.我认为符号链接无法正常工作.我该如何运作?

Images are uploading totally fine, but whenever I try to display them they're not showing, while they're displaying absolutely fine on localhost. I think the symbolic link is not working. How can I make it work?

P.s:我在cPanel上没有CLI的任何访问权限.

推荐答案

您可以使用PHP和Laravel帮助器方法执行相同操作,只需运行一次此代码(例如,将其添加到控制器中并调用一次)即可创建存储手动链接:

You can use PHP and Laravel helper methods to do the same, just run this code once (e.g. add it in your controller and call it once) to create storage link manually:

use Illuminate\Support\Facades\File;

File::link(
    storage_path('app/public'), public_path('storage')
);

这篇关于storage:链接在托管cPanel上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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