【问题标题】:Image not displayed in postman (readable) using Laravel API使用 Laravel API 在邮递员(可读)中未显示图像
【发布时间】:2019-08-29 02:04:00
【问题描述】:

图像保存到响应中指定的数据库和文件路径。试图显示图像或下载它,它不是显示的。我试图阅读相同的图像,但它正在工作。

storage_path('app/uploads/images/3.png')

我读取了存储在目录中的 3.png,它可以正常工作而不会显示错误,但要显示它不显示图像的图像。

[![if (empty($imag)){
        return response()->json(\[
            'success' => false,
            'message' => 'There was a problem creating the postcard!'
        \], 201);
    }
    return response()->json(\[
        'success' => true,
        'data' => file_get_contents(storage_path('app/public/uploads/images/'.$exportName)),
        'message' => 'Postcard created successfully!'
    \],200);
    }

图片保存的目录是storage/app/public/uploads/ 我使用了 php artisan storage:link

【问题讨论】:

    标签: laravel postman


    【解决方案1】:

    你的存储路径是

    App/upload/images/3.png

    你正在上传图片

    App/upload/public/images/3.png

    所以数据库存储在上面的路径中,图像没有上传到上面的路径中

    只需从上面的路径中删除 public 即可...

    【讨论】:

    • 虽然我已经找到了解决方案。我已经在 filesystem.php 中将路径从存储更改为公共。谢谢
    猜你喜欢
    • 2020-01-24
    • 2016-09-10
    • 2018-09-05
    • 2021-02-17
    • 2020-10-10
    • 2018-12-26
    • 2020-07-22
    • 1970-01-01
    • 2017-02-17
    相关资源
    最近更新 更多