我有一个在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);
}
答案 0 :(得分:0)
代替使用相对路径给出实际路径。这样可以解决问题。