按照我的教程,我这样做了:
public function store(Request $request)
{
$file = Input::file('imagen1');
$image = \Image::make(\Input::file('imagen1'));
$path = public_path().'/thumbnails/';
$image->save($path.$file->getClientOriginalName());
$image->resize(null, 300, function ($constraint) {
$constraint->aspectRatio();
});
$image->save($path.'thumb_'.$file->getClientOriginalName());
$thumbnail = new Thumbnail();
$thumbnail->image = $file->getClientOriginalName();
$thumbnail->save();
$request->user()->propiedades()->create($request->all());
return redirect('profile#propiedades');
}我的问题是图像保存在“时间”路径中,而不是真正的路径中。所以当我去我的桌子'Propiedades‘时,它只显示了这个:

正确的方向是这个

所以我的问题是,我如何使介入图像保存为真实路径?提前感谢
更新
好的。现在,多亏了Nazmul Hasan,我在我的数据库中看到了这个。剩下的唯一一件事就是保存文件的名称。所以我可以去我的刀片上做{{ $propiedades->imagen1 }}谢谢!

更新2
$file = Input::file('imagen1');
$ext = time() . '.' . $file->getClientOriginalExtension();
$path = public_path('thumbnails/' . $ext);
$image = \Image::make(\Input::file('imagen1'));
$image->save($path.$file->getClientOriginalName());
$image->resize(400, null, function ($constraint) {
$constraint->aspectRatio();
});
$image->save($path.'thumb_'.$file->getClientOriginalName());
$thumbnail = new Thumbnail();
$thumbnail->image = $file->getClientOriginalName();
$thumbnail->save();
$inputs = $request->all();
$inputs['imagen1'] = $path;
$request->user()->propiedades()->create($inputs);
return redirect('profile#propiedades');现在IT保存了正确的IMG路径,但图像没有保存为CORRECLTY


发布于 2016-12-05 12:37:21
你的问题出在这一行
$request->user()->propiedades()->create($request->all());您不会更新$request变量中的图像上传路径。因此,请保存临时图像路径。您可以尝试此操作
$file = Input::file('imagen1');
$image = \Image::make(\Input::file('imagen1'));
$path = public_path().'/thumbnails/';
$image->save($path.$file->getClientOriginalName());
$image->resize(null, 300, function ($constraint) {
$constraint->aspectRatio();
});
$image->save($path.'thumb_'.$file->getClientOriginalName());
$thumbnail = new Thumbnail();
$thumbnail->image = $path.'thumb_'.$file->getClientOriginalName();
$thumbnail->save();
$inputs = $request->all()
$inputs['imagen1'] = $path.$file->getClientOriginalName();
$request->user()->propiedades()->create($inputs);
return redirect('profile#propiedades');https://stackoverflow.com/questions/40965887
复制相似问题