Get the url and message after a successful upload

I’m using php/xhr to upload files (uppy/upload.php at main · transloadit/uppy · GitHub)

The “url” and “message” should be returned to the client here:

  $data = ['url' => $target_file, 'message' => 'The file ' . basename($_FILES['files']['name'][0]) . ' has been uploaded.'];
            echo json_encode($data);

I’ve added both a complete and upload-success event but I don’t seem to find the ‘url’ and ‘message’ strings in the returning variables result / file and response.

 uppy.on('complete', (result) => {

 uppy.on('upload-success', (file, response) => {

How to retrieve the data that is output with echo json_encode($data); ?

I’m not sure why it doesn’t work as I haven’t used PHP. If you figure it out it would be create to let us know so we can change the example.

Issue solved. The code I was using didn’t echo the JSON but used a return statement. That’s why the variables were not passed to the browser.