I can't access/read a file located on a network shared folder when running this code in IIS. The folder in question is set up to allow all users. If however, I run the php script through the command prompt it works fine. Doing a shell_exec('whoami') through the command prompt yields the correct user but, through the browser it comes back empty.
This is definitely something to do with setting up the proper permission or setting up the server with the right user or something along those line. I do not know much about servers so, any help on how to solve this problem or any experiment that would yield any clue is greatly appreciated.
Below is the code which is very simple and strait forward (again is IIS 2003 server PHP 5.2)
<?php
$theFile="\\\\192.168.0.16\\geo\\junk.txt"; #network file does not works
#$theFile="junk.txt"; #local file works fine
$handle = fopen($theFile, "r");
if($handle){
while (!feof($handle)){
$buffer = fgets($handle);
echo $buffer."<br />";
}
}
?>
Well, we couldn't exactly figure out what the cause of the problem was except that it was some sort of permission issue on the server where my script lives. The workaround was to create another website on the server and copy the files there. We went through every setup we could think of but, we didn't find anything different but, hey it is working now. I mean, there was a bit more to it than just doing that like creating a virtual folder of the share network address and setting the correct password but, the main fix was just create a new website on the server and forget about the headaches of the old one. Hopefully we didn't break anything while doing all the debugging