0

我已经搜索过,并没有找到这个问题的答案。

好吧,我正在使用 laravel 5.5 的干预来上传照片。当我create有一个新食谱(在我的情况下)时,一切正常,照片上传成功。

这是初始上传的代码:

$front_image = $request->file('front_image');

$frontImageName = md5(time()) . '.' . $front_image
                    ->getClientOriginalExtension();

$locationfi = public_path('photos/front/' . $frontImageName);

Image::make($front_image)
    ->resize(454,340)
    ->insert(public_path('photos/logo.png'),'bottom-right')
    ->save($locationfi);

$recipe->front = $frontImageName;

所有标准的东西。但是当我尝试edit一个食谱时,我得到了Image source not readable。这是重新上传的代码:

        $front_image = $request->file('front_image');

        $frontImageName = md5(time()).'.'.$front_image
                      ->getClientOriginalExtension();

        $location = public_path('photos/front/'.$frontImageName );

        Image::make($front_image)->resize(690,517)
            ->insert(public_path('photos/tk.png'),'bottom-right')
        ->save($location);

        //update the database
        $recipe->front=$imageName;

enctype="multipart/form-data"以两种形式使用,用于创建和更新。在更新表格上,我也使用{{method_field('PUT'}}.

我在这里想念什么?谢谢。

4

1 回答 1

0

我已经解决了这个问题。“总是为了小事”,所以他们说。当我插入徽标图像时,我指的是不存在的照片。这就是为什么它给了我错误,显然。

于 2017-09-14T14:11:25.980 回答