Php 缩略图路径不是';t保存在数据库中

Php 缩略图路径不是';t保存在数据库中,php,laravel,Php,Laravel,我有一个简单的图像上传代码,在上传时也会创建图像的缩略图。问题是缩略图保存到目录中,但在数据库中未保存缩略图的路径。原始图像的路径已正确保存 这是密码 $image = $request->file('image'); if( $image && $image->isValid()){ $imagename = str_random(20).'.'.$image->getClientOriginalExtension();

我有一个简单的图像上传代码,在上传时也会创建图像的缩略图。问题是缩略图保存到目录中,但在数据库中未保存缩略图的路径。原始图像的路径已正确保存

这是密码

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

    if( $image && $image->isValid()){

        $imagename = str_random(20).'.'.$image->getClientOriginalExtension(); 

        $destinationPath = public_path('/uploads');
        $thumb_img = Image::make($image->getRealPath())->resize(200, 200);
        $thumb_img->save($destinationPath.'/thub_'.$imagename,80);

        $destinationPath = public_path('/uploads');
        $image->move($destinationPath, $imagename);                            
    }

    $item->image = $imagename;
    $item->image_thumb = $thumb_img;
所以,
$item->image\u thumb=$thumb\u img未保存在数据库中。我还在我的模型中添加了
image\u thumb
filleble


有什么问题吗?

您需要先获取
$thumb\u img
名称,然后将其保存到数据库列中!比如:
$thumb\u img=$destinationPath./thub\u.$imagename不要忘记接受最佳答案!:)您需要先获取
$thumb\u img
名称,然后将其保存到DB列中!比如:
$thumb\u img=$destinationPath./thub\u.$imagename不要忘记接受最佳答案!:)
 $thumb_img = Image::make($image->getRealPath())->resize(200, 200);
 $thumb_img->save($destinationPath.'/thub_'.$imagename,80);
 $thumb_img = $destinationPath.'/thub_'.$imagename;