Mostrar ñ y tildes en php
Publicado por Marcial (5 intervenciones) el 24/11/2020 17:44:20
Buen dia... tengo una funcion que lista directorios en un tree view. Tengo una funcion para subir archivos a esos directorios que estan en un servidor. Al subir un archivo con ñ por ejemplo: Albañil lo sube bien al servidor sin problemas pero no se me ve en mi sistema web a la hora de cargarlo en el tree view, aca les dejo la funcion..si me pudieran ayudar gracias de antemano.
Utilizo una expresion regular la cual creo esta correcta.
Utilizo una expresion regular la cual creo esta correcta.
1
2
3
4
5
6
protected function path($id) {
$id = str_replace('/', DIRECTORY_SEPARATOR, $id);
$id = trim($id, DIRECTORY_SEPARATOR);
$id = $this->real($this->base . DIRECTORY_SEPARATOR . $id);
return $id;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public function lst($id, $with_root = false) {
$dir = $this->path($id);
$lst = @scandir($dir);
if(!$lst) { throw new Exception('Could not list path: ' . $dir); }
$res = array();
foreach($lst as $item) {
if($item == '.' || $item == '..' || $item === null) { continue; }
$tmp = preg_match('([^ a-z -я-_0-9.]+)ui', $item);
if($tmp === false || $tmp === 1) { continue; }
if(is_dir($dir . DIRECTORY_SEPARATOR . $item)) {
$res[] =array('text' => $item, 'children' => true, 'id' => $this->id($dir . DIRECTORY_SEPARATOR . $item), 'icon' => 'folder') ;
}
else {
$res[] = array('text' => $item, 'children' => false, 'id' => $this->id($dir . DIRECTORY_SEPARATOR . $item), 'type' => 'file', 'icon' => 'file file-'.substr($item, strrpos($item,'.') + 1));
}
}
if($with_root && $this->id($dir) === '/') {
$res = array(array('text' => basename($this->base), 'children' => $res, 'id' => '/', 'icon'=>'folder', 'state' => array('opened' => true, 'disabled' => true)));
}
return $res;
}
Valora esta pregunta


0