The goal is to use php to FTP into a server and get the directory listings. The only problem is that I need to use the absolute path to get to the directory.
Example:
$host = "example.com";
$port = 21;
$connection = ftp_connect($host, $port);
ftp_login($connection, "userA", "password");
ftp_pasv($connection, true);
//user's home directory is /home/userA
print_r( ftp_nlist($connection, "logs")); //works as intended
print_r( ftp_nlist($connection, "/home/userA/logs")); //does not work
The really confusing part is that using the filesystem functions with an ftp url gives me the exact opposite problem:
opendir("ftp://userA:password@example.com:21/home/userA/logs"); //works
opendir("ftp://userA:password@example.com:21/logs"); //does not work
Since the user/directory is inputted by a user, I won't necessarily know if they want to use an absolute or relative (home directory) path. I could use a simple strstr to check if the first character in the path is a "/" and choose which method to go with, but then I would end up writing twice as much code.
There's got to be an easier way to get some method to work with both absolute and relative paths. I'm hoping it's something simple that I'm just overlooking.
Thanks