My current site allows user file uploads, so, to avoid collisions i need to encode stored file names in some way. But i'd like to be able to retrieve original file names for downloads. So, i'm trying to encode file name to be
As of now, i've tried to use following code:
$hash = $file->hashName(); $fileName = base64_encode(json_encode([ 'hash' => $hash, 'name' => $file->getClientOriginalName() ])); return $fileName;
base64_encode produces longer than 256 symbols strings, especially when file name is using unicode characters (like cyrillic). So, is there any other way to encode file names?