studentA's avatar

Uploading images to database...

I want the user to be able to upload images via a form. According to the database the images have been uploaded as it states 'BLOB-20B' however when I click on it from the database, it does not open and when I try to display it via HTML, it only shows the name of the file. Does anybody know what I am doing wrong?

Controller in store: $example = new Example(); $example->sketches = request('sketches'); $example->notes = request('notes'); $example->photographs = request('photographs'); $example->save();

blade file:

sketches: {{$example -> sketches}}

Notes: {{$example -> notes}}

photographs: {{$example -> photographs}}

Database: $table->binary('sketches'); $table->binary('notes'); $table->binary('photographs');

0 likes
4 replies
jlrdw's avatar

To actually show the image, I normally use the asset helper:

<img src="{{ asset('assets/upload/imgdogs') . '/' . $row->dogpic }}" alt="" class="image">

Replace assets/upload/imgdogs with your storage location and class="image" with your css you use.

studentA's avatar

well, the file is within the database so I don't know what the path would be? I was using {{$example -> sketches}}

jlrdw's avatar

And take some of Jefferies free from scratch video training.

Please or to participate in this conversation.