simple php program upload file in database

XAMPP Version: 7.1.1

 Control Panel Version: 3.2.2

1.starting php code we need create table like as bellow

 

2.go to yout browser and type localhost//phpmyadmin  

and take a  new database.

 

3.Database name=em

4.table name=emp and

 

5.select 4 column  like

 

Eid,ename,emailid and ephoto

  

6/write this php program

<?php
 if(isset($_POST['s1']))
 {
   
    $con=mysqli_connect("localhost","root","","em");

    mysqli_query($con,"insert into emp(ename,emailid,ephoto)
    values('".$_POST['t1']."',
           '".$_POST['e1']."',
           '".$_FILES['file1']['name']."')");   
   header("location:photo.php");
 }

?>
<html>
<head></head>
<body>
<form name=f1 id=f1 method=post enctype="multipart/form-data">
Name:<input type=text name=t1 id=t1><p>
Emailid:<input type=email name=e1 id=e1><p>
File:<input type=file name=file1 id=file1><p>
<input type=submit name=s1 id=s1 value=upload>
</form>
</body>
</html>

7.after write this code

 

8.you save this file in 

C drive/xampp//htdocs

 

9.in your browser type localhost//filename.php

output like this

 10.in name 

emailid

and upload any photo like jpg,png,gif and click on upload

and go to database you was created

11.your file was uploaded.

 


Comments

Popular posts from this blog

progarmming with c++