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
[OK]
index.php:
<!doctype html>
<html>
<body>
<div id="uppy"></div>
<script src="
https://cdn.jsdelivr.net/npm/uppy@3.25.2/dist/uppy.min.js"></script>
<link href="
https://cdn.jsdelivr.net/npm/uppy@3.25.2/dist/uppy.min.css" 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'
})
</script>
</body>
</html>
server.php:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
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'];
http_response_code(400);
echo json_encode($data);
exit;
}