问题
I'm having some trouble using scandir - I have it working fine on one site but now I'm wanting to scan the same directory on that site but from a different website.
I'm using the following code:
array_diff(scandir('http://sub.domain.co.uk/folder/folder/'), array('.', '..'));
and I get this error:
Warning: scandir(http://sub.domain.co.uk/folder/folder/): failed to open dir: not implemented
I've had a Google but brought up very little - I've tried enabling directory listing on the external site and allow_fopen_url is enabled as well.
I'm stumped, any help with this one?
回答1:
Assuming you have the ftp extension loaded in PHP (PHP: FTP), you could:
$connect = ftp_connect($ftp_server);
$login_result = ftp_login($connect, $username, $password);
$contents = ftp_nlist($connect, ".");
print_r($contents);
回答2:
This turned out to be a loop back problem, I was trying to scan a a folder on the same domain which was not allowed with my host.
I've had to introduce a 'state' to deal with this which says whether the software is live or not (because the software, once live, will actually point to a different domain).
来源:https://stackoverflow.com/questions/17836389/php-using-scandir-with-and-external-url-not-implemented