<?php


$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$location = "../uploads/json/";
if (!file_exists($location)) {
    mkdir($location, 0777, true);
}
$repLoc = "/uploads/json/".$filename;
$location = "../uploads/json/".$filename;
$return_arr = array();

/* Upload file */
if(move_uploaded_file($_FILES['file']['tmp_name'],$location)){
    $src = "images/jsonPr.png";

    // checking file is image or not
    if(is_array(getimagesize($location))){
        $src = 'images/jsonPr.png';
    }

    
    $string = file_get_contents($location);
    $data = json_decode($string, true);
    $return_arr = array(
        "name" => $filename,
        "size" => $filesize, 
        "src"=> $src,
        "json"=> $data,
        "loc" => $repLoc
    );
}

echo json_encode($return_arr);