Warning: open dir: not implemented

前端 未结 4 1457
余生分开走
余生分开走 2021-01-18 01:55

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/mov

相关标签:
4条回答
  • 2021-01-18 02:07

    opendir operates on directories on a filesystem, not HTTP URIs.

    While some HTTP URIs return directory listings (the one you are using doesn't, it is a 404 error), those listings as HTML documents generated by the webserver and are not actual directories.

    0 讨论(0)
  • 2021-01-18 02:10

    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.

    0 讨论(0)
  • 2021-01-18 02:12

    Most remote servers does not send a directory listing back as such opendir cannot understand what your trying to do so it cant work.

    You will need to use something like ftp, here is an example: http://php.net/manual/en/ftp.examples-basic.php or cURL

    0 讨论(0)
  • 2021-01-18 02:23

    Manual claims this function works with URL's, however, it appears it doesn't.

    Use a local path (either relative or absolute). For example, './voorpagina/movies'. This has solved a similar problem to me before. I hope this helps.

    0 讨论(0)
提交回复
热议问题