laravel livewire干涉图像
我正在尝试使用Livewire的干预图像来缩小尺寸,但我没有成功。如果Livewire不允许,他们可以指导我或告诉我 我试图通过这种方法:laravel livewire干涉图像,laravel,file-upload,laravel-7,laravel-livewire,Laravel,File Upload,Laravel 7,Laravel Livewire,我正在尝试使用Livewire的干预图像来缩小尺寸,但我没有成功。如果Livewire不允许,他们可以指导我或告诉我 我试图通过这种方法: foreach ($this->imagenes as $pathGaleria) { $imgUrl = $pathGaleria->store('imagenesPropiedades'); $img = imgPropiedades::create([ 'u
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
]);
}
但这一页仍然是空白的。谢谢。我今天发现这个,可能对你有用 + $images=Collection::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([
]);
});