'An error occurred.', 'messages' => $errors, ]); exit; } // Get the MIME type of the bytes uploaded, using the Fileinfo extension. $finfo = new finfo(FILEINFO_MIME_TYPE); $detectedMimeType = $finfo->buffer($contents); $info = array_merge($info, [ 'detectedMimeType' => $detectedMimeType, ]); // In our example, we respond with the uploadprogress information, as well as // the detected MIME type from the initial bytes uploaded (if we can detect it). header('HTTP/1.1 200 OK'); header('Content-Type: application/json'); echo json_encode($info);