【问题标题】:Laravel - Intervention Image - Image source not readableLaravel - 干预图像 - 图像源不可读
【发布时间】:2018-02-20 11:28:10
【问题描述】:

我想用 Intervention Image 包调整我的图像大小,但是当我尝试时它给了我这个错误。

干预\图像\异常\NotReadableException
图片来源不可读

我的代码;

if ($request->hasFile('featured_image')) {

    $realname = pathinfo($request->file('featured_image')->getClientOriginalName(), PATHINFO_FILENAME);
    $extension = $request->file('featured_image')->getClientOriginalExtension();
    $new_name = $realname."-".time().".".$extension;
    $request->file('featured_image')->storeAs('public/uploads',$new_name);
    $path = Storage::url('uploads/'.$new_name);
    $post->featured_image = $path;
    Image::make($path)->resize(320, 240)->insert($path);
}

我该如何解决这个问题?

【问题讨论】:

    标签: php laravel laravel-5 intervention


    【解决方案1】:

    使用图片的完整路径而不是 URL,例如:

    Image::make(storage_path('uploads/'. $new_name'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-22
      • 2017-06-09
      • 2020-04-29
      • 2016-12-19
      • 2016-07-09
      • 1970-01-01
      • 1970-01-01
      • 2019-01-16
      相关资源
      最近更新 更多