laravel - 存储:链接在托管 cPanel 上不起作用
问题描述
我已经创建了一个存储链接,php artisan storage:link
它在localhost上运行良好,但是,当我在共享主机上部署我的项目时,它不会呈现任何图像。这是我的托管目录结构:
- 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
图像上传没有任何问题,但是当我尝试渲染它们时它们不会渲染,而它们在本地主机上被渲染得非常好。我认为符号链接不起作用。我怎样才能让它工作?
Ps:我在 cPanel 上没有 CLI 的任何访问权限。
解决方案
您可以使用 PHP 和 Laravel 辅助方法来做同样的事情,只需运行一次此代码(例如,将其添加到您的控制器并调用一次)以手动创建存储链接:
use Illuminate\Support\Facades\File;
File::link(
storage_path('app/public'), public_path('storage')
);
推荐阅读
- powerbi - 从 Microsoft Power BI 中表的每一行中减去度量值
- kubernetes - 如何处理 ConfigMaps 中的秘密?
- android - 在本机反应中使用html元素格式化字符串
- c# - 还有什么可能阻止 manifest.json 被提供?
- css - rgba 效果在使用 SASS 或 CSS 变量时不适用
- python - 使用python从csv获取数据并将它们写入字典的问题
- .net - 无法在传入邮件标头中检索在 WCF 中添加传出邮件标头
- python-3.x - keepalive 设置 paho.mqtt 简单 API 自动断开连接
- c++ - 当我们在 C++ 中说“初始化对象”时,实际上是什么意思?
- agda - `isoToEquiv` 和 `iso` 的定义是什么?