It is very simple. At first create a form then create a MySQL table and now insert file into the database. follow this code
HTML code:
<form method="post" enctype="multipart/form-data"> <input type="file" name="file_upload"> <button type="submit" name="upload">Upload Image</button> </form>
PHP code:
<?php if(isset($_POST['upload'])){ $img_file =$_FILES["file_upload"]["name"]; move_uploaded_file($_FILES['file_upload']['tmp_name'],'uploads/images/'.$img_file); $qry=mysqli_query($con,"INSERT INTO `table name` (`image_file`) values ('".$img_file."')"); if($qry){ echo "Uploaded Successfully"; } else{ echo "Uploaded Failed !!"; } } ?>
Either or visit this link:
Question and answer is powered by AnsPress.io