Hi im using the next function to create a tree directory menu in my website, the directories include a lot of pdf and excel, sometimes the name of this files have accents, spaces and ñ, My application work perfectly in OSX (mac) but a soon I uploaded in my godaddy server (linux), all the characters with accent were replace by the ?
character breaking all the names and the link. Do you know how to deal with this issue? I been reading about urlencode, urlrawencode, inclusive I read, this comment in the php documentation site as comment:
Scandir does not work properly with non-english caracters (like french accents for example : éàçè...) in the files name. As PHP does not support unicode operations until PHP 6, this is not a bug.
I hope somebody can help me in solve this.
function listFolderFiles($dir){
$ffs = scandir($dir);
echo '<ul class="transparencia">';
foreach($ffs as $ff){
if($ff != '.' && $ff != '..' && $ff != '.DS_Store'){
$stringFileDir = $dir.'/'.$ff;
echo '<li>';
if(is_file($stringFileDir)){
echo "<a href='transparencia/".$dir.'/'.$ff."' data-type='".pathinfo($stringFileDir)['extension']."' target='_blank'>".$ff."</a>";
}else{
echo "<span class='more'>+</span>".urldecode($ff);
}
if(is_dir($dir.'/'.$ff)){
listFolderFiles($dir.'/'.$ff);
}
echo '</li>';
}
}
echo '</ul>';
}