2

Possible Duplicate:
PHP - opendir on another server

Something like this:

opendir(http://super.cdn.com/running_order_image/sale/587/)

The opendir is being used to check the contents of a Rackspace Cloud Files Akamai bucket.

I am looping through a structure like this

587/
587/587_rubyred
587/587_rubyred/front.jpg
587/587_rubyred/back.jpg

I am trying to return the 587_rubyred part. Basically my MySQL query loops through the 587 and 834 and other numbers, I then check the directory for those numbers and return the first subfolder.

Community
  • 1
  • 1
TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209

5 Answers5

3

This is not possible. The most servers have the directory listing disabled and doesn't send a directory list opendir is for local directories.

PHP - opendir on another server

You can access over ftp or something else.

Community
  • 1
  • 1
René Höhle
  • 26,716
  • 22
  • 73
  • 82
2

No. There is no concept of a directory in URLs.

A URL might map on to a directory on the server's filesystem, but that mapping is not exposed by HTTP.

http://example/running_order_image/sale/587/ might give you an HTML document with links to everything in a directory on the server, but you would have to access it like any other resource, then parse the HTML to get the URLs to those resources.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

If you want to connect to rackspace cloud files, I'd suggest using the API located at https://github.com/rackspace/php-cloudfiles

$auth = new CF_Authentication('<RACKSPACELOGIN>','<RACKSPACEKEY>');
$auth->authenticate();
$conn = new CF_Connection($auth);
$cloudFolder = $conn->get_container('<RACKSPACECONTAINER>');    
$cloudImages = $cloudFolder->get_objects();

foreach($cloudImages as $image)
{
  echo '<li>' . $image->name . '</li>';
}

edit: you will then be able to perform the following

$cloudImages = $cloudFolder->get_objects(0,NULL,NULL,'587/587_rubyred');
Scuzzy
  • 12,186
  • 1
  • 46
  • 46
0

Why don't you look in the specs?

http://nl3.php.net/manual/en/function.opendir.php

Look under changelog:

4.3.0 path can also be any URL which supports directory listing, however only the file:// URL wrapper supports this in PHP 4

So if this works depends on the server you approaching. I know my servers won't allow it. ;-)

Erwin Moller
  • 2,375
  • 14
  • 22
0

Try to use FTP in PHP. This will allow you to remotely connect to the server. Of course only if it is allowed to connect via FTP.

Juris Vaiders
  • 635
  • 8
  • 22