I am trying to upload and save an image file to my database table. But now I am stuck with my code and I need someone to help me out. When I hit my save button it will echo failure to save file.
profile.php
<div class="profile">
<form action="photo.php" method="POST" enctype="multipart/form-data">
<h2>Upload File</h2>
<label for="fileSelect">Filename:</label>
<input type="file" name="photo" id="fileSelect">
<input type="submit" name="submit" value="save">
<p><strong>Note:</strong> Only .jpg, .jpeg, .gif, .png formats allowed to a max size of 5 MB.</p>
</form>
</div>
save.php
<?php
include 'db.php';
if(isset( $_POST['photo'])){
$photo = $_POST['photo'];
$sql = "INSERT INTO users (photo) VALUE ('$photo')";
$query = mysqli_query($conn,$sql);
header("Location:profile.php");
}else{
echo "failure to save file!";
}
?>