Working state

This commit is contained in:
julien
2026-03-16 02:55:50 +01:00
parent 55d2da9f2f
commit 1f4262d952
2 changed files with 21 additions and 3 deletions

View File

@@ -87,7 +87,7 @@ final class MediaController
public function upload(Request $req, Response $res): Response
{
$files = $req->getUploadedFiles();
$uploadedFile = $files['image'] ?? null;
$uploadedFile = $files['file'] ?? $files['image'] ?? null;
if ($uploadedFile === null || $uploadedFile->getError() !== UPLOAD_ERR_OK) {
return $this->jsonError($res, "Aucun fichier reçu ou erreur d'upload", 400);
@@ -103,7 +103,12 @@ final class MediaController
return $this->jsonError($res, $e->getMessage(), 500);
}
return $this->jsonSuccess($res, $url);
$res->getBody()->write(json_encode([
'success' => true,
'url' => $url,
], JSON_THROW_ON_ERROR));
return $res->withHeader('Content-Type', 'application/json')->withStatus(200);
}
/**