Améliore l'édition du site public
This commit is contained in:
parent
e786756f22
commit
81f259ea6e
11 changed files with 123 additions and 26 deletions
|
|
@ -775,8 +775,22 @@ final class SettingsController
|
|||
$filename = ImageService::storeUploaded((string) $upload['tmp_name'], $directory, 'site', 'photo');
|
||||
@chmod($directory, 0755);
|
||||
AuditService::log('public_site_image_uploaded', '/settings/public-site/image', 'Image du site public ajoutée');
|
||||
if (str_contains((string) ($_SERVER['HTTP_ACCEPT'] ?? ''), 'application/json')) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode([
|
||||
'filename' => $filename,
|
||||
'url' => '/media/site/' . rawurlencode($filename),
|
||||
], JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||
exit();
|
||||
}
|
||||
header('Location: /settings/public-site?image=' . rawurlencode($filename));
|
||||
} catch (Throwable $e) {
|
||||
if (str_contains((string) ($_SERVER['HTTP_ACCEPT'] ?? ''), 'application/json')) {
|
||||
http_response_code(422);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode(['error' => SecurityService::publicError($e)], JSON_THROW_ON_ERROR);
|
||||
exit();
|
||||
}
|
||||
header('Location: /settings/public-site?error=' . rawurlencode(SecurityService::publicError($e)));
|
||||
}
|
||||
exit();
|
||||
|
|
|
|||
Loading…
Reference in a new issue