How to get images from database in cakephp

how to get images from database in cakephp

Step 1: Explain what you mean by “get images from database”.
Step 2: Tell us about the database structure where the images are stored.
Step 3: Show us what you’ve tried, and explain what’s not working about it.


i save my images in webroot after uploading by forms now i want to access these images on my index.ct form i save image name in database and images upload in webrooot my own directory

See the docs, but something like:

<td><?php echo $this->Html->image('imgdogs/' . $quy->dogpic, array(
                                'class' => 'imgborder',
                                'alt' => ''
                            )); ?></td>

or just a regular image tag:

echo '<img src="' . DIR . 'upload/imgrecent/' . $row->pic4 . '" width="280" class="imgborder">';

DIR is a constant I use.

plz inform me bro what’s mean by $row->pic4 we are fetching pic4 only or by this statment we can fetch all require images

$row->pic4 is just his “placeholder”.
This should be replaced with your specific property.

It should be obvious that if more than one you need to setup a foreach loop.

And handle if one is empty.

if (empty($row->your_pic)) {
                echo "";  // or a default // or however you need
            } else {
                // display the image

If you are new to this stuff, I’d highly advise finding and taking some basic html, php, css, and JS tutorials.