<?php 
//require("functions.php");
//$targetFolder = ($_REQUEST['target'] == "btn")?"btn":"image";
$target_dir = "../img/banner/";
$fileIndex = "stripHeaderImage";
$imageFileType = pathinfo($_FILES['stripHeaderImage']['name'],PATHINFO_EXTENSION);
$target_file = uniqid(null,true) . "." . $imageFileType;

$uploadOk = 1;


// Check if image file is a actual image or fake image

if (strtolower($imageFileType) != "jpg" && strtolower($imageFileType) != "png") {
	$data['error'] = "This image is not valid, at least does not have the .jpg, or .png extension. FileType: " . $imageFileType;
	
	$data['files'] = print_r($_FILES,true);
}else{
		$temp = $target_dir . $target_file;
	if (move_uploaded_file($_FILES[$fileIndex]["tmp_name"], $temp )) {
	        $data['message'] = "The file ". basename( $_FILES[$fileIndex]["name"]). " has been uploaded and renamed to \"" . $target_file . "\"";
	        $data['url'] = "$target_dir" . $target_file;
			$data['target_file'] = $target_file;
	        $data['fileuploaded'] = true;
	    } else {
			//var_dump($_FILES);
	        $data['error'] = "Sorry, there was an error uploading your file.";
	    }
}

header('Content-Type: application/json');

echo json_encode($data);

?>