简体   繁体   中英

Remove points dir($path)

I am developing an application in which an administrator can upload files and you can read about users.

The problem I have when as shown, points dir($path) me appear;

Attached a picture with the problem:

删除圆内的点

I want to remove the points!

As I can do that do not appear? I tried CSS and find some other way to develop but no way.

This is the code:

$path="../administrador/entrenos/"; 
$directorio=dir($path);
while ($archivo = $directorio->read())
    {
    $descarga = $path."".$archivo;
            echo "<a href=".$descarga.">".$archivo."</a><br>";

        }   
$directorio->close();

any ideas?

You can try to do this:

while ($archivo = $directorio->read())
    {
    if ($archivo == "." || $archivo == "..") {
       continue;
    }
    $descarga = $path."".$archivo;
            echo "<a href=".$descarga.">".$archivo."</a><br>";

        } 

Add the below code to not display the dir with . and ..

while ($archivo = $directorio->read()){
    if($archivo === '.' || $archivo === '..') {continue;}
    $descarga = $path."".$archivo;
    echo "<a href=".$descarga.">".$archivo."</a><br>";

}

Another approach with array_diff and scandir can be implemented like below.

$path = "../administrador/entrenos/";
array_walk(array_diff(scandir($path), ['.', '..']), function ($archivo) use ($path) {
    $descarga = $path . $archivo;
    echo "<a href='{$descarga}'>{$archivo}</a><br>";
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM