<?php require "../vendor/autoload.php";
// Requests from the same server don't have a HTTP_ORIGIN header
ini_set('display_errors', true);


use IntellexApps\PHP\UploadFile\UploadFileController;

if (!array_key_exists('HTTP_ORIGIN', $_SERVER)) {
	$_SERVER['HTTP_ORIGIN'] = $_SERVER['SERVER_NAME'];
}

try {
	$API = new UploadFileController($_REQUEST['request'], $_SERVER['HTTP_ORIGIN']);
	echo $API->processAPI();
} catch (Exception $e) {
	echo json_encode(Array('error' => $e->getMessage()));
}