<?php
include"../../../../inc/conn.php";

// CEK HAK AKSES DISINI


$target_dir_foto    = "../../../../assets/gambar/";
$target_file_foto   = $target_dir_foto . basename($_FILES["foto"]["name"]);
$imageFileTypeFoto  = pathinfo($target_file_foto,PATHINFO_EXTENSION);
$namafile 			= date('Ymds').".".$imageFileTypeFoto;


$simpan = mysqli_query($connect,"insert into tb_media set 

		file 			= '".$namafile."'

")or die(mysqli_error($connect));


if($simpan){
	move_uploaded_file($_FILES['foto']['tmp_name'],"../../../../assets/gambar/$namafile");
	echo"<script>alert('Media berhasil disimpan !');</script>";
	echo"<script>document.location.href='datamedia'</script>";
}else{
	echo"<script>alert('Gagal mengeksekusi perintah ini !');history.go(-1)</script>";
}
?>