我试图使用Livewire的介入图像来减小尺寸,但我没有成功。如果Livewire可能不允许,他们可以引导我或告诉我。
我正在尝试通过这个方法:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);以另一种方式:
foreach ($this->imagenes as $pathGaleria) {
$imgUrl = $pathGaleria->store('imagenesPropiedades');
Image::make($pathGaleria)->resize(1200, null, function ($constraint) {
$constraint->aspectRatio();
})
->save($imgUrl);
$img = imgPropiedades::create([
'url' => $imgUrl,
'property_id' => $this->propiedadId
]);
}但是页面仍然是空白的。谢谢。
发布于 2020-12-11 07:19:01
我今天找到了这个,可能对你有用
https://gist.github.com/daugaard47/659984245d31b895d00ee5dcbdee44ec
+
$images =集合::wrap($request->file(‘file’));
$images->each(function ($image) use ($id) {
$basename = Str::random();
$original = $basename . '.' . $image->getClientOriginalExtension();
$thumbnail = $basename . '_thumb.' . $image->getClientOriginalExtension();
ImageManager::make($image)
->fit(250, 250)
->save(public_path('/images/' . $thumbnail));
$image->move(public_path('/images/'), $original);
Model::create([
]);
});https://stackoverflow.com/questions/65134937
复制相似问题