Laravel使用中です。
自サイトにアップロードしてある画像を取得してサーバーに保存する処理を、練習で作成しておりますが、以下のようなエラーになってしまい画像が保存できておりませんでした。
Can't write image data to path
保存先のフォルダのパーミッションは777、https環境です。
原因がわかる方、アドバイスをお願い致します。
Controller
php
1$imagePath = 'https://example.com/image.jpg'; //保存したい画像のURL 2$file = file_get_contents($imagePath); 3$destPath = sprintf('photos/original/%d', $id); //保存先のディレクトリ 4$destPath = $destPath.'/'.pathinfo($imagePath, PATHINFO_BASENAME); //保存先のディレクトリとファイル名 5 6//保存先フォルダの存在確認 7if (!file_exists(public_path().'/storage/photos/original/'.$id)) { 8 \Log::debug('フォルダは存在しています。'); //ログにはこの文章が残っていた。 9} 10 11$image = Image::make($file); 12$image->save(public_path().'/storage/' . $destPath); //ここでエラー発生
回答3件
あなたの回答
tips
プレビュー