29488

PHP Using Scandir with and External URL - Not Implemented

Question:

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?

Answer1:

Assuming you have the ftp extension loaded in PHP (<a href="http://www.php.net/manual/en/book.ftp.php" rel="nofollow">PHP: FTP</a>), you could:

$connect = ftp_connect($ftp_server); $login_result = ftp_login($connect, $username, $password); $contents = ftp_nlist($connect, "."); print_r($contents);

Answer2:

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

Recommend

  • Adding libraries to portable python
  • Way to represent unknown file size in FTP LIST?
  • Celery + Redis - .get() hangs indefinitely after running smoothly for ~70 hours
  • What is happening when this code calls FUSE like this?
  • Add Jpanel to Jframe NetBeans
  • typescript: any difference between number[] and [number,number]?
  • detecting connection lost in spark streaming
  • CUDA NSight is not installed with CUDA 5.0 installation file on Windows 8? [closed]
  • Netezza Incremental load from Sql server using SSIS
  • LNK1104: cannot open file 'kernel32.lib'
  • Changing Jupyter Notebook start up folder by modifying “start in” not working any more
  • List images(01.png) and descriptions(01.txt) from directory
  • Problems installing Yesod for Haskell
  • Copy to all folders batch file?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Unable to install Git-core+svn by MacPorts
  • C: Incompatible pointer type initializing
  • How to test if a URL from an Eclipse bundle is a directory?
  • VSO Build — Response status code does not indicate success: 404 (Not Found)
  • How to delay loading a property with linq to sql external mapping?
  • Paperclip, set path outside of rails root folder
  • ilmerge with a PFX file
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • Proper folder structure for lots of source files
  • Benchmarking RAM performance - UWP and C#
  • Load html files in TinyMce
  • Hits per day in Google Big Query
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Append folder name and increment by 1 using batch script
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass