https://team-lab.github.io/skillup/step2/image_document.html
こちらのサイトを参考にして、Base64形式にて画像表示させようとしたのですが、
画像表示する画面に切り替わったらエラーが発生します。
修正内容はマイグレーションファイルを
$table->string('image'); →→→ $table->text('image');
にしたのと以下内容になります。
対処法ご存知の方いらっしゃいましたら、なにとぞ宜しくお願い致します。
■Controller
//$filename = $request->file('image')->store('public/image'); // $post->image = basename($filename); ↓ $post->image = base64_encode(file_get_contents($request->image->getRealPath())); ``` ■view ``` <!-- <img class="card-img" src="{{ asset('storage/image/'.$post->image)}}"> --> ↓ <img class="card-img" src="data:image/png;base64,<?= $image ?>"> ``` ■エラー (1/2) ErrorException Undefined variable: image (2/2) ErrorException Undefined variable: image (View: /app/resources/views/posts/show.blade.php) [環境] windows 10 postgreSQL(Heroku)
回答1件
あなたの回答
tips
プレビュー