Added: Date time string to filename

This commit is contained in:
Luc Mcgrady 2025-09-25 12:41:52 +01:00
parent 1cdfbb08d8
commit 9685c60e8f
No known key found for this signature in database
GPG Key ID: 4F3D7A0B17CC3D9C

View File

@ -12,8 +12,10 @@ class ExportController extends BaseController
if (file_exists($databasePath))
{
$dateTimeString = date('Y-m-d-H:i:s');
$response = $response->withHeader('Content-Type', 'application/octet-stream');
$response = $response->withHeader('Content-Disposition', 'attachment; filename="grocy.db"');
$response = $response->withHeader('Content-Disposition', "attachment; filename=\"grocy-$dateTimeString.db\"");
$response = $response->withHeader('Content-Length', filesize($databasePath));
$response->getBody()->write(file_get_contents($databasePath));
return $response;