PHP Using Scandir with and External URL - Not Implemented

微笑、不失礼 提交于 2019-12-25 10:57:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!