This commit is contained in:
2023-08-25 11:30:57 +10:00
parent f50e6ad209
commit 622229cfc9
7 changed files with 243 additions and 106 deletions

View File

@@ -6,14 +6,15 @@
/**
* Generate a temporary file path.
*
* @return str The filtered array.
* @param string $extension The file extension to use.
* @return string The filtered array.
*/
function generateTempFilePath(): string
function generateTempFilePath(string $extension = ''): string
{
$temporaryDir = storage_path('app/tmp');
if (is_dir($temporaryDir) === false) {
mkdir($temporaryDir, 0777, true);
}
return $temporaryDir . DIRECTORY_SEPARATOR . uniqid('upload_', true);
return $temporaryDir . DIRECTORY_SEPARATOR . uniqid('upload_', true) . ($extension !== '' ? ".{$extension}" : '');
}