<?php 

$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["csv"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$target_file = $target_dir . $_REQUEST['for'] . ".csv";

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

if (strtolower($imageFileType) != "csv") {
	$data['error'] = "This file is not a CSV file, at least does not have the .csv extension.";
}else{
	
	if (move_uploaded_file($_FILES["csv"]["tmp_name"], $target_file)) {
	        $data['message'] = "The file ". basename( $_FILES["csv"]["name"]). " has been uploaded.";
	        $data['fileuploaded'] = true;
	    } else {
	        $data['error'] = "Sorry, there was an error uploading your file.";
	    }
}

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

echo json_encode($data);

?>