<?php
session_start();
if($_SESSION['status']!=''){
include"../inc/conn.php";

// CEK HAK AKSES DISINI


$id  		= str_replace("'","`",(isset($_SESSION['id_siswa'])) ? $_SESSION['id_siswa'] : "");



  $target_dir_foto    = "../assets/foto/";
  $target_file_foto   = $target_dir_foto . basename($_FILES["file_foto"]["name"]);
  $imageFileTypeFoto  = pathinfo($target_file_foto,PATHINFO_EXTENSION);


  if($imageFileTypeFoto!="jpg"){
    echo"<script>alert('Please select jpg file !');history.go(-1)</script>";
  }elseif($_FILES['file_foto']['size']>100000){
    echo"<script>alert('Max size 100Kb !');history.go(-1)</script>";
  }else{
    $file_name  = md5($id).".jpg";
    move_uploaded_file($_FILES['file_foto']['tmp_name'],"../assets/foto/$file_name");
    echo"<script>alert('Photo berhasil diupload !');history.go(-1)</script>";
  }



}else{
  echo"<script>document.location.href='index.php'</script>";
}
?>