Alle anderen Informationen, die in der Datenbank gespeichert werden, sind auf der Website nur nicht das Bild, das ein BLOB-Bild ist. Die Datenbank hält das Bild so, als ob Sie es drücken würden, um das gespeicherte Bild anzuzeigen. Irgendwelche geschätzt!Bild wird nicht von der Datenbank empfangen
GetImage.php
<?php
include "connection.php";
$ID = $_GET["ID"];
$SQLCommand = "SELECT * FROM products WHERE ID = '$ID'";
$Result = mysqli_query($con, $SQLCommand);
$row = mysqli_fetch_assoc($Result);
header("Content-type:" . $row["Name"]);
echo $row["Image"];
?>
shop.php
<?php
include "connection.php";
$SQLCommand = "SELECT * FROM products";
$Result = mysqli_query($con, $SQLCommand);
while($row = mysqli_fetch_assoc($Result)){
echo "<p id='p1'>" . $row["Name"] .
"<br></p><p id='p3'>£" . $row["Price"] .
"<br><br><img src=GetImage.php?ID=" . $row["ID"] . " width=10%>" .
"<br><a href=productdetails.php?ID=" . $row["ID"] . ">Details</a></p>".
"<p id='p2'><a href=BasketAdd.php?ID=" . $row["ID"] . ">Add to Basket</a><br><br>";
}
?>
InsertImageform
<html>
<body>
<form action="UploadFile.php" method="post"
enctype = "multipart/form-data">
Name: <input type="text" name="name" id="name"><p>
Description: <input type="text" name="description" id="description"><p>
Price: <input type="text" name="price" id="price"><p>
Protein: <input type="text" name="protein" id="protein"><p>
Type: <input type="text" name="type" id="type"><p>
Filename: <input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
** WARNUNG **: Bei der Verwendung von 'mysqli' Sie verwenden sollten [parametrisierte Abfragen] (http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) und ['bind_param'] (http://php.net/manual/en/mysqli-stmt.bind- param.php) um Benutzerdaten zu Ihrer Anfrage hinzuzufügen. ** Verwenden Sie NICHT ** String-Interpolation oder Verkettung, um dies zu erreichen, weil Sie einen schwerwiegenden [SQL injection bug] erstellt haben (http://bobby-tables.com/). ** NIEMALS ** $ _POST 'oder' $ _GET' Daten direkt in eine Abfrage einfügen, es kann sehr schädlich sein, wenn jemand versucht, Ihren Fehler auszunutzen. – tadman