SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)

    opendir() - Remote dir with http://

    As my topic says, I'm interested in using opendir() with an http:// URL. Is that even possible? We're running Apache and PHP 4.4.6.

    Any help would be greatly appreciated.

    We have set chmod to 777, and have Options +Indexes and Options All Indexes in the .htaccess file but I still get the error "failed to opendir: not implemented in <filename>"

  2. #2
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, you can't do it with opendir().

    You could retrieve the raw HTML and match the urls to the files via preg_match/ereg_match and then do stuff with the results, but that's about it.

    AFAIK

  3. #3
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep. opendir() doesn't work over HTTP protocol. HTTP is simply a data transfer protocol.

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you running the server that you're trying to opendir()? If so, and FTP is an option, you can connect to the server using FTP and retrieve the directory listing that way. Otherwise, use regular expressions on the HTML output.

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    We also tried FTP and couldn't get it to work. I was trying to use the URL in the form of FTP://userass@domain/folder and if I put that in my browser it'd bring up what I wanted, but not if I tried to use it in opendir(). I don't run the server myself, but I'm pretty sure that the one that did it had put chmod 777 and such, so I don't know what else we could have changed to get it to work. (We were getting the same "not implemented" error).

  6. #6
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need PHP5 or greater to use an FTP path with opendir(). Otherwise you should use ftp_connect() and ftp_nlist() to list files.

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Okay, thanks.

    I do have one more question. On the PHP page, it said that 4.3 supported any wrapper that supports directory listing, and I thought HTTP did support it.

  8. #8
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samanime View Post
    Okay, thanks.

    I do have one more question. On the PHP page, it said that 4.3 supported any wrapper that supports directory listing, and I thought HTTP did support it.
    Most HTTP daemons (e.g. Apache, IIS, etc.) support showing a Directory Index, or listing of files in a given directory. However, there is no LIST command in the HTTP protocol.

    The Directory Index is simple a HTML formatted list of the files in the folder, not a pure listing. As there is no standard way to list files in a directory over HTTP, it's not a valid wrapper.

  9. #9
    SitePoint Member
    Join Date
    May 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, I'm not sure, but maybe try curl [on a linux server and or in PHP.] or wget. But I'm not sure.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •