Accessing a share directory on a Ip

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
javedkarim
Forum Newbie
Posts: 3
Joined: Fri Jun 27, 2008 6:48 am

Accessing a share directory on a Ip

Post by javedkarim »

:banghead: :banghead: :banghead:
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. :banghead: i know this too but i need an other way.

Here is my code for accessing the directories( which wont work ) . :banghead:

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>
 
Is Apache restricting the access.
Post Reply