Skip to content

Instantly share code, notes, and snippets.

@Ivanitch
Created January 25, 2023 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ivanitch/c275111ad20d2fac72ce06b8139bd35c to your computer and use it in GitHub Desktop.
Save Ivanitch/c275111ad20d2fac72ce06b8139bd35c to your computer and use it in GitHub Desktop.
Generate file name
protected function getFilename(UploadedFile $file): string
{
$hash = sha1_file($file->tempName);
$name = substr_replace($hash, '/', 3, 0);
$name = substr_replace($name, '/', 7, 0);
return $name . DIRECTORY_SEPARATOR . $file->extension;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment