Show/get error message in Uppy Dashboard

I have created some minimalist code to display the error message generated by the server in the dashboard. All I see is “upload failed” and not the error “File size exceeds the maximum allowed size” that is returned by server.php.

When I click on the “?” in the dashboard, a popup opens with the text

Upload failed

Failed to upload fileabc.txt Upload error



<!doctype html>
      <div id="uppy"></div>
      <script src=""></script>
      <link href="" rel="stylesheet">
      <script >
         let uppy = new Uppy.Uppy();
         uppy.use(Uppy.Dashboard, {
                 inline: true
                 , bundle: true
                 , height: 500
                 , width: 900
                 , target: '#uppy'
                 , method: 'post'
             .use(Uppy.XHRUpload, {
                 endpoint: 'server.php'


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_FILES["file"])) {
    header('Access-Control-Allow-Origin: *');
    header('Content-type: application/json');
    $data = ['message' => 'File size exceeds the maximum allowed size'];
    echo json_encode($data);