List directory by network

Asked

Viewed 1,247 times

3

I am using the code below to read files:
Locally it works, but when I put the variable $dir with a network path, as below, I get error:

$dir = "W:/_Infraestrutura/Controles/Inventario de Equipamentos/ " ;   
$pasta= opendir($dir);    
echo "<ul data-role='listview' data-inset='false' data-filter='true'>";   
echo("<li data-role='list-divider'><a href='#'>A</a></li>"); 

while ($arquivo = readdir($pasta)){
    if ($arquivo != '.' && $arquivo != '..'){
        echo "<li><a href='".$dir.$arquivo."' rel='external' >".$arquivo."</a></li>";
        }
}

Warning: opendir(W:/_Infrastructure/Controls/Inventory of Equipments/ ,W:/_Infrastructure/ Controls/ Inventory of Equipments/ ): in C: wamp www terms index.php on line 26

Warning: opendir(W:/_Infrastructure/Controls/Inventory of Equipments/ ): failed to open dir: No such file or directory in C: wamp www terms

Warning: readdir() expects Parameter 1 to be Resource, Boolean Given in C: wamp www terms index.php on line 31 index.php on line 26

  • Try to pass the ip in place of the mapped drive.

  • @rray while passing IP, error remains

  • when Voce uses the opendir() the code looks for the path inside the folder itself, try going up some levels to see if it works, use .../

  • @Rafaelacioly would be ".. /.. /.. /CAMINHO"?

  • Exactly, make a var_dump($pasta) or print_r($pasta) and then die() just to see where you are and find and folder where you want to get. or use getcwd to display the directory name where Voce is located.

  • @Rafaelacioly same error =/

  • You need to specify the protocol, use opendir("ftp://...") or ftp_connect This question is answered here: https://stackoverflow.com/questions/5292984/php-opendir-on-another-server

  • You need to see if the Apache user is allowed to access the network

  • In Windows environment is backslash. W:\_Infraes....

  • For questions if the path is correct, press Windows+R. Copy the path in the dialog box and give an OK or ENTER. If you don’t, the path is wrong.

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.