Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 8, 2020 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/f6937660e616c598b7acb06dec0ca8b3 to your computer and use it in GitHub Desktop.
Save parzibyte/f6937660e616c598b7acb06dec0ca8b3 to your computer and use it in GitHub Desktop.
<?php
include_once "bd.php";
$id = $_GET["id"];
if (empty($id)) {
exit("No existe el parámetro id en la URL");
}
$sentencia = $base_de_datos->prepare("SELECT foto FROM fotos WHERE id = ?");
$sentencia->execute([$id]);
$foto = $sentencia->fetchObject();
if (!$foto) {
exit("No hay foto con ese ID");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ver foto</title>
</head>
<body>
<h1>Foto:</h1>
<img src="data:image/png;base64,<?php echo $foto->foto; ?>">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment