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
@rray while passing IP, error remains
– Lucas Torres
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.../
– RFL
@Rafaelacioly would be ".. /.. /.. /CAMINHO"?
– Lucas Torres
Exactly, make a
var_dump($pasta)
orprint_r($pasta)
and thendie()
just to see where you are and find and folder where you want to get. or usegetcwd
to display the directory name where Voce is located.– RFL
@Rafaelacioly same error =/
– Lucas Torres
You need to specify the protocol, use
opendir("ftp://...")
orftp_connect
This question is answered here: https://stackoverflow.com/questions/5292984/php-opendir-on-another-server– Fabio Nogueira
You need to see if the Apache user is allowed to access the network
– Bacco
In Windows environment is backslash.
W:\_Infraes....
– Daniel Omine
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.
– Daniel Omine