문제

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.

도움이 되었습니까?

해결책

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');

다른 팁

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.

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.

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. ;-)

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top