Refactor filename generation for user uploads to use a timestamp for uniqueness and filesystem safety
This commit is contained in:
parent
5499482637
commit
787c32fdf5
BIN
assets/images/profilePictures/user_10_69769485461a7618397775.jpg
Normal file
BIN
assets/images/profilePictures/user_10_69769485461a7618397775.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
@ -106,10 +106,10 @@ if (!is_writable($targetDir))
|
||||
exit();
|
||||
}
|
||||
|
||||
// Fallback-kompatibler Name (auch ohne random_bytes)
|
||||
$rand = uniqid('', true);
|
||||
$rand = str_replace('.', '', $rand);
|
||||
$filename = 'user_' . $userId . '_' . $rand . '.' . $ext;
|
||||
// Dateiname: user_<ID>_<Datum>.<ext>
|
||||
// Format ist dateisystem-sicher (keine Doppelpunkte) und eindeutig genug.
|
||||
$timestamp = gmdate('Ymd-His');
|
||||
$filename = 'user_' . $userId . '_' . $timestamp . '.' . $ext;
|
||||
$targetPath = rtrim($targetDir, "\\/") . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
if (!move_uploaded_file($tmp, $targetPath))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user