maminya.aka 0 Newbie Poster

This my form

`<form enctype="multipart/form-data" action="upload.php" method="POST" > 
    <table> 
    <tr> 
    <td>Name :</td> <td><input type="text" placeholder="Name" id="text3"></td> 
    </tr> 

    <tr> 
    <td>Chose File : <input type="file"  name="image" /></td> <td> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"/> 
    </td> 
    </tr> 

    <tr> 
    <td></td> 
    <td><input type="submit" value="upload"/></td> 
    </tr> 
    </table> 
</form>  

`

code to upload image

<?php 
include ("koneksi.php");
// error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
$uploaddir='desain/';

$filename=$_FILES['image']['name'];

$uploadfile=$uploaddir.$filename;

$tmpName=$_FILES['image']['tmp_name'];

$fileSize=$_FILES['image']['size'];

$fileType=$_FILES['image']['type'];


$query ="SELECT count(*) as jum FROM upload WHERE name='$filename'";
$hasil=mysql_query($query);
$data=mysqli_fetch_array($hasil);

if($data['jum']>0)
{
    $query="UPDATE upload SET sze='$fileSize' WHERE name='$filename'";

}
else
{
    $query="INSERT INTO upload (name,type,size,location) VALUES('$filename','$fileType','$fileSize','$uploadfile')" or die ("gagal".mysql_error());
}


if(move_uploaded_file($_FILES['image']['tmp_name'],$uploadfile))

{
    echo "Done";
}
else
{
    echo "Failed";
}

?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.