How can I allow user to upload file via AJAX. Then read that file using PHP

I am trying to build a file reader on my website. The background idea is for the user to be able to select a JSON file from their PC. Choose it using an upload function on my website, then view the contents of that JSON file on that same page.

I currently have working code for the decoding and outputting of the JSON file. The part I am struggling with is the file upload, and reading the data from the uplaoded file.

The reason I am struggling is that I don’t want the file to be uploaded to my site. I am hoping for the file to be temporary, or read via AJAX and the data outputted from that file. Once the page refreshes, the file and data will be gone. This is designed so I don’t have hundreds of files being uploaded to my website.

The working code I currently have below allows me to change the file url currently with a select form. This works and on the form submit, the php variable $url changes to the option value in the dropdown.

I am now hoping to replace this dropdown select with an upload function so the user can choose any JSON file from their PC.

<script>
<?php 
    if($_POST['Submit']) {
        $url = $_POST['urlchooser'];
        echo $url;
        var_dump($url);
    } else {
        $url = "Choose JSON File";
        echo "Choose JSON File";
        var_dump($url);
    }
?> 
</script>
<form action="" method="post" id="form">
    <select name="urlchooser">
        <option value="<?php echo $url ?>">
            Choose JSON File       
        </option>
        <option value="file1.json">File 1</option>
        <option value="file2.json">File 2</option>
    <input type="submit" name="Submit" id="formsubmit" value="Select File">
</form>

The form above changes the php variable $url which is used to decode and read the file. (I haven’t included all of the decode and output code as this is incredibly long and working fine)

Thanks