<?php

$fileinfo = @getimagesize($proofPurchase["tmp_name"]);

$allowed = [
    'jpg',
    'png',
    'jpeg'
];

// Get image file extension
$file_extension = pathinfo($proofPurchase["name"], PATHINFO_EXTENSION);

// Validate file input to check if is not empty
if (! file_exists($proofPurchase["tmp_name"])) {
    $response = array(
        "type" => "error",
        "message" => "Choose image file to upload."
    );
} else {


    $temp = explode(".", $proofPurchase["name"]);
    $newFileName = round(microtime(true)) . '.' . end($temp);

    $target = "views/admin/img/pof/" . $newFileName;
    if (move_uploaded_file($proofPurchase["tmp_name"], $target)) {
        $response = array(
            "type" => "success",
            "message" => "Image uploaded successfully."
        );
    } else {
        $response = array(
            "type" => "error",
            "message" => "Problem in uploading image files."
        );
    }
}

?>