我的图像不显示在我的网站的前端,但它是在后端


My images are not displaying in the front-end of my site, but it is in the backend

我有一个汽车公司的后端。这样他们就可以管理他们的车辆库存,并在他们的网站上显示"出售"项目。

后端与网站位于同一服务器的子目录下。

在这个子目录中,我有一个文件夹,其中上传的图像是从后端表单存储的。这些都100%有效。整个后端像它应该的那样工作。

这里的问题,只要我通过数据库循环查看网站上的图像,它不显示。DB中的所有其他数据都显示得很好,但图像不显示。

这是我的代码。

<?php
$conn = new mysqli($serverName, $username, $password, $dbName);
if ($conn->connect_error) {
    die('Connection to database failed: ' . $conn->connect_error);
}
$sql = "SELECT * FROM vehicles";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
   while ($row = $result->fetch_assoc()) {
?>


<table width="100%">
    <tbody>
    <tr>
        <td>
            <table width="100%">
                <tbody>
                <tr>
                    <td><?php echo $row['make']; ?> <?php echo $row['model']; ?></td>
                    <td><?php echo $row['price']; ?></td>
                </tr>
                </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%">
                <tbody>
                <tr>
                    <td>
                        <?php
                            $dir="http://myurl/uploaded_images/";
                        $filePath = $row['images_path'];
                        $fileArray = explode("*", $filePath);
                        foreach ($fileArray as $file) {
                            if (file_exists($dir.$file)) {
                                echo "<img src='$dir/$file'>";
                            }
                        }
                        echo $row['images_path'];
                        ?>
                    </td>
                    <td>
                        <?php echo $row['price']; ?>
                    </td>
                </tr>
                </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    </tbody>
</table>
<?php
    }
}
?>

我认为前端是Joomla值得注意。我正在使用一个名为Sourcerer的插件,将PHP代码包含在一篇文章中。

将类似的代码替换为

foreach ($fileArray as $file) {
    if (file_exists($dir.$file)) {
        echo '<img src="'.$dir.$file.'">';
    }
}