【问题标题】:Laravel Storage Link on Sub-domain子域上的 Laravel 存储链接
【发布时间】:2021-09-04 08:26:45
【问题描述】:

我在本地环境中使用 Laravel 7 创建了一个 Web 应用程序,它有一个选项,用户可以上传和更改他们的个人资料图片。 它在本地环境中运行良好。 最近我将此项目上传到子域下的实时服务器。我将所有公共文件放在子域文件夹中,将其他文件放在根目录中。 像这样。
File Structure
而现在当我跑步时

php artisan storage:link

它在 files/public/images 中上传图片 我需要图片到 hello.example.com/images

文件上传代码

if ($request->hasFile('profile_image')) {
    $image = $request->file('profile_image');
    $name = time() . '.' . $image->getClientOriginalExtension();
    $path = '/images/';
    $destinationPath = public_path('images');
    $image->move($destinationPath, $name);
    $user_image = '';
    if (isset($name)) {
        $user_image = $path . $name;
    }
}

【问题讨论】:

    标签: php laravel image web file-upload


    【解决方案1】:

    我已经添加了它关注的人 这在我的 index.php

    $app->bind('path.public', function() { return _DIR_; });

    并删除 flyestream.php 链接,它对我有用

    【讨论】:

    • 谢谢,我试过了,但不知何故得到了错误Undefined constant "_DIR_任何解决方案?
    猜你喜欢
    • 2021-10-19
    • 2018-10-15
    • 1970-01-01
    • 2019-01-11
    • 2018-01-31
    • 2018-06-20
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    相关资源
    最近更新 更多