<LINK href="images/index.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    function refreshAndClose() {
        window.opener.location.reload(true);
        window.close();
    }
</script>
<body onbeforeunload="refreshAndClose();">

<?php
$allowed = array('png', 'jpg','jpeg');
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
	$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);
	if(!in_array(strtolower($extension), $allowed)){
		echo '{"status":"error"}';
		exit;
	}
$dir1 = $_POST["dir"];
$filename = $_FILES['upl']['name'];
	if(move_uploaded_file($_FILES['upl']['tmp_name'], ''.$dir1.'/'.$_FILES['upl']['name'])){

include("index.db.php");
mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$ukey1 = $_POST['ukey'];
$query = "UPDATE $tahun_now Set FOTO = '$filename' where UKEY = '$ukey1'";  
$result = mysql_query($query); 
		//-----------------
		echo '<b>UPLOAD FILE TELAH DISIMPAN SILAHKAN TUTUP JENDELA INI</b>';
		exit;
	}
}
echo '{"status":"error"}';
exit;
?>
