I am currently attempting to upload images from my HTML form to a MySQL BLOB column.
Here is the current relevant code for my HTML code (input file type is just a placeholder, I will of course change it out to whatever it must be. These values are in table data form, but I condensed it down to be easier to read)
<form method="post" action="inspectionprocessing.php">
<input type="text" name ="unit" value="">
<input type="text" name ="notes" value="">
<input type="file" name ="media">
<input type="submit" value="Submit Inspections" name="submit">
</form>
Here is the code to insert into MySQL.
//Establishing variables
$unitNumber = $_POST["unit"];
$unitNotes = $_POST ["notes"];
$unitMedia = $_POST ["media"];
// Create connection
$con = mysqli_connect($host, $username, $password);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
echo "";
//Query database
$sql = "INSERT into inspect.building_1 (Unit, Notes, Media) values ('$unitNumber','$unitNotes', '$unitMedia')";
$inspection = mysqli_query($con, $sql);
Here is the code to display information from the database
$sql = "SELECT * FROM inspect.building_1 ";
$apartments = mysqli_query($con, $sql);
while($apartment = mysqli_fetch_assoc($apartments)){
echo "<tr>";
echo "<td>" . $apartment ["Unit"] . "</td>";
echo "<td>" . $apartment ["Notes"] . "</td>";
echo "<td>" . $apartment ["Media"] . "</td>";
echo "<td>" . $apartment ["Date"] . "</td>";
echo "<td>" . $apartment ["InspectionID"] . "</td>";
In sum, I m looking for HTML code to upload multiple images to a table under one InspectionID in the database. I need the database to store the images and display them on a separate page. I am totally open to a file path, but I will need all of the necessary code - I am very much a beginner here doing it all for the first time. Thank you so much for your help!
Images if you want to know what it looks like.
Note: Database connections and everything works, I only need help with images