I've been trying to no avail to read either a directory or a file from a network using PHP. The operation works fine if the directories are local but, I have had ZERO luck with the network. My system admin told me that the folders I'm trying to accessed are shared. I can also read the files using python. There are two folders in question I want to access, one with a user name and password while the other one has no protection. For the sake of this particular problem I would be happy just to be able to access the one without the password protection. All it has in it is a junk file that i put there as an experiment. The code in question which is a simple experiment code is found below. The error I received is: Warning: opendir(M:,M:): The system cannot find the path specified. (code:" 3)
<?php
$location = "\\\\192.168.0.16\\geo";
$user = "";
$pass = "";
$letter = "M";
system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");
$dir = $letter . ":";
#if(is_dir($dir)){
if($dh = opendir($dir)){
while(($file = readdir($dh)) !== false){
echo "filename: $file : filetype: ".filetype($dir . $file) . "\n";
}
closedir($dh);
}
#}
?>