Uploading image and storing it in MySQL Database
Hi there guys can someone help me with this simple profile code. Everything is perfect I just wanna store Profile Pictures in the database. Can someone help me add simple code to upload photo to database???
My code is as follows
Code:
<html>
<head></head>
<body>
<?php
$username=$_POST['username'];
$password=$_POST['password'];
$confirm_password=$_POST['confirm_password'];
$email=$_POST['email'];
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$conn=mysql_connect("localhost","root","******") or die('Error');
mysql_select_db("oracle",$conn) or die('Error');
$sql="INSERT INTO profile (username,password,confirm_password,email,first_name,last_name,image)//image attribute in DB is blob type.
VALUES ('$username','$password','$confirm_password','$email','$first_name','$last_name',' ')";
mysql_query($sql,$conn);
mysql_close($conn);
}
?>
<form method="post" action="test.php" enctype="multipart/form-data">
Username :<input type="text" name="username"/><br>
Password :<input type="text" name="password"/><br>
Confirm Password : <input type="text" name="confirm_password"/><br>
Email : <input type="text" name="email"/><br>
First Name :<input type="text" name="first_name"/><br>
Last Name :<input type="text" name="last_name"/><br>
Upload Image :<input type="file" name="image" id="file"><br>
<input type="submit" value="Submit"/>
</form>
</body>
</html>