Page 1 of 1

readdir remote directories, php.ini

Posted: Fri Sep 26, 2003 2:38 pm
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);  
}

Posted: Fri Sep 26, 2003 3:22 pm
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.

Posted: Mon Sep 29, 2003 2:24 pm
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?

Posted: Mon Sep 29, 2003 2:43 pm
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)