<?php include "../../root.class.php";
$db = new db_safeguard();

if (isset($_POST['ajax_type']) && $_POST['ajax_type'] == "file_upload") {

    try {
        $file_save_path = $_POST['file_save_path'];

        $target_dir = $file_save_path;

        $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

        $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
           echo "OK";
        } else {
            echo "0";
        }
        
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}