Please tell me where the error is, why the transliteration of the file name does not work?
<?php
$s = $_FILES['passport_file']['name'];
function translit($s) {
$s = (string) $s;
$s = strip_tags($s);
$s = str_replace(array("
", ""), " ", $s);
$s = preg_replace("/\s+/", ' ', $s);
$s = trim($s);
$s = function_exists('mb_strtolower') ? mb_strtolower($s) : strtolower($s);
$s = strtr($s, array('а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'e','ж'=>'j','з'=>'z','и'=>'i','й'=>'y','к'=>'k','л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch','ш'=>'sh','щ'=>'shch','ы'=>'y','э'=>'e','ю'=>'yu','я'=>'ya','ъ'=>'','ь'=>''));
$s = preg_replace("/[^0-9a-z-_ ]/i", "", $s);
$s = str_replace(" ", "-", $s);
return $s;
}
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/files/users/'.$_POST['id'].'/passport/';
move_uploaded_file($_FILES['passport_file']['tmp_name'], $uploaddir . $s);
?>