Open a Blank page with an image when clicked from the Database (PHP)

Asked

Viewed 50 times

-1

I am able to list in HTML all the images saved in my database, but I would like to click on any, open a Blank page with the image, but I do not know what to put in href, because the image data comes from the database.

Code:

<span class="ml-2">
   <a href="O QUE COLOCO AQUI?" target="_blank">
      <img class="img-fluid" src="<?= 'data:' . $anexo['tipo'] . ';base64,' . base64_encode($anexo['arquivo']) ?>" alt="Photo" style="width: 80px; height: 80px !important;">
   </a>
</span>

Database:

inserir a descrição da imagem aqui

  • if you don’t have a url to post, use #

1 answer

1

If you want to open the image on another screen, put the path to the image. Example:

href="folder/image.jpg" target="_Blank"

in your case, put the same that is in the image src inside the href:

<?= 'data:' . $anexo['tipo'] . ';base64,' . base64_encode($anexo['arquivo']) ?>
  • I’ve tried, open a page with nothing.

  • Put the code you are using on href.

Browser other questions tagged

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