Hi
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.
Here is my code for accessing the directories( which wont work ) .
Code: Select all
<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)."\n";
closedir( $dir );
?></pre>