Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: open dir: not implemented

Tags:

php

I'm new to PHP, and I'm trying to build a script. When I load the script, I get the following error:

Warning: opendir(http://www.hetweerinboskamp.nl/voorpagina/movies) [function.opendir]: failed to open dir: not implemented

<?php
    $hal ='';
    $dir ='http://www.hetweerinboskamp.nl/voorpagina/movies';
    if ($handle = opendir($dir)) {
        // Loop the folders
        while (false !== ($file = readdir($handle))) {
            if(strlen($file) > 4) {
                $rawd = parsename($file);
                $hal.= 'new Date('.substr($rawd,0,4).', '.substr($rawd,4,2).'-1, '.substr($rawd,6,2).'),';
                 //$hal.= $rawd.',';
             }

            closedir($handle);
         }
like image 823
Geert Avatar asked Aug 18 '12 11:08

Geert


1 Answers

opendir() is used to open a local directory and since PHP 5.0.0 on an ftp directory.

If your PHP code runs on www.hetweerinboskamp.nl then /voorpagina/movies is actually a local directory and you can do this:

$dir ='<wwwroot>/voorpagina/movies';
if ($handle = opendir($dir)) {

where wwwroot is the root of the filesystem as seen by your php code.

If you're trying to download content from another website, try e.g. file_get_contents(). Note that if the remote server lists the content of a directory the listing is in fact an HTML page generated on the fly by the server. You may find yourself needing to parse that page. A better approach is to check whether the server offers some sort of API where it sends back the content in a standardized form, e.g. in JSON format.

like image 104
Adam Zalcman Avatar answered Oct 04 '22 12:10

Adam Zalcman