readdir remote directories, php.ini

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
User avatar
jeanloui
Forum Commoner
Posts: 36
Joined: Fri Sep 26, 2003 2:38 pm
Location: Girona (Europe)

readdir remote directories, php.ini

Post by jeanloui »

I'm using readdir to list local directories and files and it works fine!

But when I try to read remote directories (located in another server, lets say http://www.grn.es/imagic/audio/ readdir does not recognize the directory path.

It seemed, first, to be a problem of "opendir" or of php back slash preferences (\"http:) but I read an interesting quote at:
http://io.spaceports.com/~wysardry/php/ ... files.html
that tells that I must enable "allow_url_fopen" in my local php (4.1.2).
OK, so I must edit the php.ini
Mac OS X does not comes with php.ini You must create one for special purposes... see:
http://www.wellho.net/forum/5660076501.html
So I'm in process of creating a new php.ini to open this unprotected remote directories... or copying the php 4.3.1 php.ini where it must be, reboot the server and risk the experinece...

If there is an easyest way to do so, please post the shortcut! THANKS!

here comes the code:

Code: Select all

$path_to_files = '/Library/WebServer/Documents/portal/audio' ;  // local dir, works fine! 
$path_to_files = 'http://www.grn.es/imagic/audio' ;             // remote dir, does not work ;( 

if ( $handle = opendir ($path_to_files)) { 
    echo "Directory handle: $handle \n";
    echo "Files:\n" ;

    while (false !== ($file = readdir ($handle))) {  
        echo "$file \n";
    } 
     closedir ($handle);  
}
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://php.net/opendir wrote: As of PHP 4.3.0 path can also be any URL which supports directory listing, however only the file:// url wrapper supports this in PHP 4.3. As of PHP 5.0.0, support for the ftp:// url wrapper is included as well.
User avatar
jeanloui
Forum Commoner
Posts: 36
Joined: Fri Sep 26, 2003 2:38 pm
Location: Girona (Europe)

Post by jeanloui »

volka wrote: As of PHP 4.3.0 path can also be any URL which supports directory listing, however only the file:// url wrapper supports this in PHP 4.3. As of PHP 5.0.0, support for the ftp:// url wrapper is included as well.
Do you mean that if I use php 4.3.0 and use the same code it will work?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

no, it says that even with php5 there is no remote directory listing for http.
There simply is no such thing provided by http. If you can see a directory listing on a webserver it is created by something like mod_autoindex for apache or similar but that's neither a standard nor something php can parse (by default)
Post Reply