Created
December 6, 2018 04:24
-
-
Save ErMandeep/f6fb349b302ec01d15220b1d39d3d303 to your computer and use it in GitHub Desktop.
Encripted image insert and fetch from database in php ( save image in database without upload move to any folder )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// image upload query | |
if(count($_FILES["image"]["tmp_name"]) > 0) | |
{ | |
for($count = 0; $count < count($_FILES["image"]["tmp_name"]); $count++) | |
{ | |
$image_file = addslashes(file_get_contents($_FILES["image"]["tmp_name"][$count])); | |
$query = "INSERT INTO images (productID, image) VALUES ('$id_guests', '$image_file')"; | |
$result= mysqli_query($connection,$query); | |
} | |
} | |
?> | |
<!-- fetch blob images --> | |
<?php | |
$view_images = "SELECT * FROM images WHERE productID= $productID"; | |
$select_imgs = mysqli_query($connection, $view_images); | |
while($row = mysqli_fetch_assoc($select_imgs)){ | |
$id_img = $row['id']; | |
$img = $row['image']; | |
?> | |
<img src="data:image/jpeg;base64,<?php echo base64_encode($img); ?>" style="height:220px; width:220px; " /> | |
<a href="vendor-dashboard-add-listing.php?p_id=" class= "trash" >Remove</a> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment