Display image<img src=""> from the database path to PHP webpage

32 views Asked by At

I would like to display/load image from the database, my image path is stored in database. My project file is in different drive (d:) and my images are in share drive (Z:). Currently I am working on localhost. When I inspect my webpage, shows my path, but it give error in console as "Not allowed to load local resource:".

below is my code:

while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
 $imageURL =  $row['Bildpfad'];
                        
                        $color = ($row['ErgebnisOrig'] == "0") ? "#43D934" : ($row['ErgebnisOrig'] == "1" ? "#F36565" : 
                                        ($row['ErgebnisOrig'] == "2" ? "#F3CE32" : "#6E6E6E"));  // check for nIO IO NA
                        $erg = ($row['ErgebnisOrig'] == "0") ? "IO" : ($row['ErgebnisOrig'] == "1" ? "nIO" : 
                                        ($row['ErgebnisOrig'] == "2" ? "NA" : "nres"));  // display text of IO nIO NA and nres 
                        // Generate HTML for each image
                        echo "<div class='outer_block$counter'><div class = 'st_$counter'>".$condition['MessStation']."</div>
                        <div class='st_$counter'></div>
                        <div class='s_$counter'></div>
                        <div class='erg_$counter' style='background-color:".$color."'>$erg</div>
                        <div class='dt_$counter'>$datePart</div>
                        <div class='time_$counter'>$timePart</div>
                        <div class='inner_block$counter'><img src='$imageURL' class='img$counter' onclick='redirectToLayerPage()'></div>
                        </div>";
                        $counter++;
                    }
                }

Please suggest me how to display/load local images/share drive images to webpage in PHP

0

There are 0 answers