I want to store image in database directly without storing it in a folder on my explorer. If possible than how? I am using php with mysql database to store image and i have define datatype LONGBLOB to store image in database. Below is my code:
   <?php
$conn = mysqli_connect("localhost","root","")or die(mysqli_error($conn));
mysqli_select_db($conn,'image') or die(mysqli_error($conn));
if(isset($_REQUEST['submit'])){
$old = $_FILES['img']['tmp_name'];
$new = $_FILES['img']['name'];
move_uploaded_file($old,$new);
echo $sql = "INSERT INTO img(`img_name`) VALUES('$new')";
$exe = mysqli_query($conn,$sql);
if($exe){
    echo "Image Uploaded Successfully....";
    }
}
echo $query = "Select `img_name` from `img`";
$ex = mysqli_query($conn,$query);
?>
<html>
    <body>
        <form method="post" name="myForm" id="myForm" enctype="multipart/form-data">
            <div>
                <input type="file" name="img"/>
            </div>
            <div>
                <input type="submit" name="submit" value="Upload"/>
            </div>
            <?php
                while($res = mysqli_fetch_array($ex)){
            ?>
            <div>
                <img height="50" width="50" src="<?php echo $res['img_name'];?>"/><br/>
            </div>
            <?php } ?>
        </form>
    </body>
</html>
 
     
     
    