
Can't write image data to path (/work/storage/app/public
のようなエラーが出る場合。
どうやら環境によっては、直接保存できいないらしい。
大丈夫な例
保存するときはStorage::putを使う。
use Illuminate\Support\Facades\Storage;
//中略
$img = Image::make($request->file)->resize(300, 300, function ($constraint) {
$constraint->aspectRatio();
})->stream('jpg', 100);
Storage::put('/public/icon/'. $fileName.'.jpg', $img);
ダメな例
$img = Image::make($request->file)->resize(300, 300, function ($constraint) {
$constraint->aspectRatio();
})->stream('jpg', 100);
Storage::put('/public/icon/'. $fileName.'.jpg', $img);//直接保存はできないことがある
LaravelでIntervention/image で圧縮した画像をファイルに保存せずにバイナリで取得する方法
Intervention Image | Intervention Image v2 | intervention.io