View images in the database with a separate cakephp file

Asked

Viewed 69 times

0

I am using phpcake as an administrator of a photo gallery, the images are saved inside the webroot/img/galleries/ folder for each category a folder is created following a numbering. Up to there everything is working.

The problem is when I list the images in a file outside of phpcake only using pure php, I use the following code to call the images

<?php
    $photos = $conexao->query("SELECT * FROM images WHERE galeria_id = $album_id");
        while($photo_data = $photos->fetch_assoc()) { ?>
        <div class="col-lg-4">
<img class="img-responsive" src=admin/webroot/img/galerias/"<?php echo $photo_data['galeria_id'] ?><?php echo $photo_data['image'] ?>" />
        </div>
    <?php }
    ?>

After that it returns me an error in the console of Chrome 403 (Forbidden) the in the path of the photo it adds %222bb1d11f-ea8a-4a27-b6f8-f28b1e5098ea.jpg%22 those %222 at the beginning and end of the image. I just wanted to put the id that is equal to the folder number and then the path that is saved in the image.

1 answer

0

Place double quotes at the beginning of the image path:

src="admin/webroot/img/galerias/`<?php echo $photo_data['galeria_id'] ?><?php echo $photo_data['image']` ?>"

And make sure that this is even the image address, because I’m pretty sure there’s a bar (/) missing between the codes php, and I’m also pretty sure that there’s something missing or missing at the beginning of the path...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.