Update: I have uploaded images using PHP BLOB, but they are not showing up in mysql table. Images are being moved to the destination folder but are not showing up in table. and when I fetch the images this code nothing shows up
Code for uploading images
<?php
if (isset($_POST['add_p'])) {
@$pn = $_POST['pname'];
@$pp = $_POST['pprice'];
@$pc = $_POST['pcategory'];
@$date = date('d-m-y H:i:s');
$img = $_FILES['img']['name'];
$tmp_img = $_FILES['img']['tmp_name'];
move_uploaded_file($tmp_img, "uploads/$img");
$insert = "INSERT INTO products (`p_name`, `p_price`, `img`, `p_category`, `date_added`) VALUES ('$pn', '$pp', '$img', '$pc', '$date')";
mysqli_query($con, $insert);
}
?>
<form action="add-product.php" method="POST" class="form">
Name: <input class="inpt" type="text" name="pname">
Price: <input class="inpt" type="text" name="pprice">
Upload Image: <input class="inpt" type="file" name="img">
Select Category
<select class="inpt" name="pcategory">
<option>Men</option>
<option>Women</option>
<option>Kids</option>
</select>
<input type="submit" name="add_p" value="Add Product">
</form>
Code for fetching images
<?php
$get = "SELECT * FROM products ORDER BY p_id DESC LIMIT 0,4";
$query = mysqli_query($con, $get);
while ($row = mysqli_fetch_array($query)) {
echo $id = $row['p_id'];
echo $n = $row['p_name'];
echo $p = $row['p_price'];
echo $c = $row['p_category'];
echo $i = $row['img'];
}
?>