Reputation: 2291
I want to find files in ftp.
We have a tree path like this: ftp://documents.mycomp.com/mycomp/2017/companies/code/file.pdf and the php source you can find here: ftp://documents.mycomp.com/php/get_File.php.
On the testing location, my pc, it works fine. But finding on the ftp-server is a problem...
$directory = "../mycomp/2017/compX/57719/"
$root = getcwd();
$result = scandir($root . substr($directory, 2), SCANDIR_SORT_ASCENDING);
foreach($result as $fileName)
{
...;
$files[] = substr($directory, 2) . $fileName;
}
...
Result:
$files[x] = "../mycomp/2017/compX/57719/premiumList.pdf"
Upvotes: 0
Views: 2264
Reputation: 202262
Not sure I understand your problem.
Though if you want to use scandir
on the FTP server, you have to pass in an ftp://
URL like:
$result = scandir("ftp://example.com/directory/to/list/");
You of course need to have fopen wrappers enabled (it's enabled by default).
Alternatively, use FTP function ftp_nlist
.
Upvotes: 2