Personally I have the routine below that makes the listing of files of a directory:
if (is_dir($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (!in_array($file, array(".", ".."))) {
$html->NOMEARQ = utf8_encode($file);
$html->DATAARQ = date("d/m/Y", filemtime($dir . $file));
$html->TAMANHO = fGetNumero(filesize($dir . $file) / 1000) . " KB";
$html->LINKARQ = "/arquivos/arquivos.download?p=docs&f=" . utf8_encode($file);
$html->block("BLOCK_LISTAGEM");
$qtdarq++;
}
}
closedir($dh);
}
It turns out that my development machine is Windows10 with Apache, and the server is Ubuntu with Apache, on my machine it normally reads the names of files with special characters,
But when I put into production in Ubuntu / Apache I have to remove the utf8_encode function otherwise it will mess up the whole file name.
I know this is because windows and linux treat different names of files, it seems to me that windows uses ANSI and Linux UTF8.
Is there a way to handle this without having to modify my PHP code when putting it on the server?
I can not change the names of the files, remove the accents and the like.