I had tired a lot to access a shared network directory on LAN but i was not successful please help me how could i access the shared directory on a ip address using php. I am running windows xp and WAMP( Apache, MYSQL , PHP 5.26 ) server on it.
Here is the code i have tried and please do not correct the code give a solution to a problem this script works fine for the directories shared on my Ip address but not works for other ip address so please tell me what wrong.
Is there any other approach for access the shared files on a network.
Please Do not tell me to mount the network directories in windows XP and then try to access them in php. i know this too but i need an other way.
Here is my code for accessing the directories( which wont work ) .
<pre><?php
$ip = '192.168.XX.XX';
$host = gethostbyaddr( $ip );
if ( $ip == $host )
die( 'Unable to resolve hostname from ip '.$ip );
$path = '//'.$host.'/directory';
if ( !is_dir($path) )
die( $path. ' is not a directory' ); //here it gives me error :: is not a directory even the path is correct.
$dir = opendir($path);
if ( $dir == FALSE )
die( 'Cannot read '.$path );
while (($file = readdir($dir)) !== FALSE)
echo "filename: $file : filetype: ".filetype( $path.$file)."\
";
closedir( $dir );
?></pre>
Well i have posted it on other forums too no one has replied me yet only the things they have helped was correcting the same things as you have.
Come on people there are other ways to build LAN search engine in php. Please some one guide how could i access the shared file on the network using any other programing language or guide me how should i build a LAN search engine. I have heard that php can also be used as desktop development language( or any any other language ) may be from there i can build an application that can read the shared network directories and stores the result in databases and using php web i can interact with database and search the required results.
Any other ideas how should i access the shared network directories using programming languages.
Any method which are slow or fast please tell me.
I assume you have mounted the network drive on the XP machine and it worked fine?
First of all PHP can open networked drives.
Also, the access to the drive needs to be previously authenticated, so the authentication process need not be done by PHP, which cannot do it. Meaning that it will only work if you opened the network drive manually first using explorer and supplied to proper credentials (login & password), which the system then used automatically for all future connections.
If no authentication has been done such as you already mounting the drive manually then it will default to the anonymous user for apache. You could setup an FTP service or SSH service on the other XP machine and pull data via a socket.
I have read the this post since there is no password in the shared network directories it depend on other people weather they give password for there sharing or not.
If this i Apache problem should i go for IIS
You could try IIS and see what happens. If the same thing happens on IIS then more than likely it’s not an HTTP server issue but a limitation of PHP itself.