how to upload/insert image into database using php mysql code example

Example 1: how to upload image in php and store in database and folder

// Get the name of images
  	$Get_image_name = $_FILES['image']['name'];
  	
  	// image Path
  	$image_Path = "images/".basename($Get_image_name);

  	$sql = "INSERT INTO student_table (imagename, contact) VALUES ('$Get_image_name', 'USA')";
  	
	// Run SQL query
  	mysqli_query($conn, $sql);

  	if (move_uploaded_file($_FILES['image']['tmp_name'], $image_Path)) {
  		echo "Your Image uploaded successfully";
  	}else{
  		echo  "Not Insert Image";
  	}
  }

Example 2: insert image in php

<body> 
<?php 
    echo "<img src='path/to/myphoto.jpg' alt='a photoe' />"; 
?> 
</body>

Tags:

Php Example