elFinder not showing Folder or File with umlaute

1.3k Views Asked by At

i encountered a problem with elFinder. When on the server there is a file or a folder containing one of the letters öäü, the directory(file) wont be shown in el finder and i get an error in

lFinderConnector.class.php json_encode(): Invalid UTF-8 sequence in argument

but if i upload a file with elFinder itself like: Test ö.png its shown correctly and on the server it looks like this: Test ö.png. Same goes for directorys.

My problem is i have a millions of files that may countain umlaute (ö,ü ,ä) and elFinder cant show them.

Does any one else got problem like this or got any idea or tip how to solwe it?

2

There are 2 best solutions below

0
On

Your solution replaces the umlauts by ASCII chars, for me it worked by just using utf8_encode() on the items of $data array before json_encode() and outputting it (it keeps the umlauts).
I took your snippet, modified it and added it to the elFinderConnector class.

protected function array_walk_deep(&$items){
foreach ($items as &$item) {
    if(is_array($item)) {
        $this->array_walk_deep($item);
    } else {            
        $item = utf8_encode($item);
    }
}

Then call it on the $data array in the output() method.

$this->array_walk_deep($data);
exit(json_encode($data));
0
On
setlocale(LC_ALL, 'de_DE');
function array_walk_deep(&$items){
    foreach ($items as &$item) {
        if(is_array($item)) {
          array_walk_deep($item);
         } else {
            if (!strpos($item ,'ö')) {
                $item = iconv('UTF-8', 'ASCII//TRANSLIT', utf8_encode($item)) ;
            }

        }
    }
}

array_walk_deep($data);

so i just made a workaround on this. In the elFinderConnector i just use this piece of code before i return the array to javascript this will change the ö->oe the ä->ae and the ü-> ue will no longer cause any problems and the directorys will be shown. Directory and files can be renamed afterward by the users. Hope some one will finde this usefull.

regrads