<?php
chdir('../');
require_once 'autoload.php';
$admin = new admin_controller;
$session = new session;
$uni = new university_controller;

$info = $uni->index();

date_default_timezone_set($info['timezone']);


if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['csrf_token']) && $waf->csrf_validate($_POST['csrf_form_id'], $_POST['csrf_token'], $utility->action_name())) {

$file_name = $utility->generateReference();

$ext = $utility->extension($_FILES);
$file = $file;
$upload_status = $utility->uploader('storage/images/students/', $_FILES, $file_name, 'png,jpeg,jpg');
$file = $file.'.'.$ext;

if ($upload_status == "OK") {

$_SESSION['application'] = $_POST;
$_SESSION['application']['reference'] = $file_name;
header("location:../payment");

}else{


$utility->setMessage("warning", 'Check your image and try again');
header("location:../");

}

}else{
$utility->setMessage("warning", 'Invalid form validation');
header("location:../");
}
?>
