PHP iconv()
Try to encode the $name1
yet again to a different encoding, Windows-1252.
//encode to windows-1252 to save to the filesystem
$name1 = $_FILES["file"]["name"]; //here is ča ča ča.doc
$encoded_filename = iconv("UTF-8","Windows-1252//IGNORE",$name1);
or CP858
$name1 = $_FILES["file"]["name"]; //here is ča ča ča.doc
$encoded_filename = iconv("UTF-8", "CP858//IGNORE", $name1)
After 30 min r&d on this, i found, you could try this:
$search = array('š','á','ž','í','ě','é','ř','ň','ý','č',' ');
$replace = array('s','a','z','i','e','e','r','n','y','c','-');
$code_encoding = "UTF-8"; // this is my guess, but put whatever is yours
$os_encoding = "CP-1250"; // this is my guess, but put whatever is yours
$name1 = $_FILES["file"]["name"];
$name1 = iconv($os_encoding , $code_encoding, $name1); // convert before replace
$name1 = str_replace($search, $replace, $name1);
Reference: https://stackoverflow.com/a/1767011/2236219