When try to add images stored in my database and display them in the page it gives me an error message saying: Failed to load resource: the server responded with a status of 404 (Not Found) how can i fix this? Here is the code:
PHP:
<?php
declare(strict_types = 1);
require 'includes/connection.inc.php';
require 'includes/Functions.inc.php';
$sql = "SELECT a.id, a.title, a.summary, a.category_id, a.member_id,
c.name AS category,
CONCAT(m.forename, ' ', m.surname) AS author,
i.file AS image_file,
i.alt AS image_alt
FROM article AS a
JOIN category AS c ON a.category_id = c.id
JOIN member AS m ON a.member_id = m.id
LEFT JOIN image AS i ON a.image_id = i.id
WHERE a.published = 1
ORDER BY a.id DESC
LIMIT 6;";
$articles = pdo($pdo, $sql)->fetchAll();
$sql = "SELECT id, name FROM category WHERE navigation = 1;";
$navigation = pdo($pdo, $sql)->fetchAll();
$section = '';
$title = 'Creative Folk';
$description = 'A collective of creatives for hire'; // Meta description content
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<main class="container grid" id="content">
<?php foreach ($articles as $article) { ?>
<article class="summary">
<a href="article.php?id=<?= $article['id'] ?>">
<img src="../uploads/<?= htmlspecialchars($article['image_file']) ?>" alt="<?= htmlspecialchars($article['image_alt']) ?>">
<h2><?= htmlspecialchars($article['title']) ?></h2>
<p><?= htmlspecialchars($article['summary']) ?></p>
</a>
<p class="credit">
Posted in <a href="category.php?id=<?= $article['category_id'] ?>">
<?= htmlspecialchars($article['category']) ?></a>
by <a href="member.php?id=<?= $article['member_id'] ?>">
<?= htmlspecialchars($article['author']) ?></a>
</p>
</article>
<?php } ?>
</main>
</body>
</html>