laravel项目可在localhost上运行,但在部署后无法在gcloud上运行

时间:2019-07-24 06:57:52

标签: php laravel gcloud

我有一个在gcloud上运行的laravel项目,但是图像上传功能显示错误,并且该功能在localhost上可以完美运行。 请帮助我修复它,在此先感谢

 $gallery = new Gallery;
 $filename = $image->getClientOriginalName();
 $org_path = '../public/images/gallery/originals/' . $filename;
 $thm_path = '../public/images/gallery/thumbnails/' . $filename;

 $gallery->image     = 'images/gallery/originals/'.$filename;
 $gallery->thumbnail = 'images/gallery/thumbnails/'.$filename;
 $gallery->title     = $request->title;
 $gallery->status    = $request->status;

 if ( ! $gallery->save()) {
    flash('Gallery could not be updated.')->error()->important();
    return redirect()->back()->withInput();
 }

 if (($org_img && $thm_img) == true) {
    Image::make($image)->fit(900, 500, function ($constraint) {
          $constraint->upsize();
    })->save($org_path);
    Image::make($image)->fit(270, 160, function ($constraint) {
        $constraint->upsize();
    })->save($thm_path);
  }

enter image description here

1 个答案:

答案 0 :(得分:0)

代替使用相对路径给出实际路径。这样可以解决问题。