문제

I have a folder mounted on the server that points to an sftp site. I need to check via php whether we can see the folders inside it.

I tried

file_exists("/path/to/the/mount/folder");

but its returning false (which I kind of expected), I can navigate to it through the file system and using terminal.

(also tried is_dir && is_link)

Here's how I mounted it from the shell

echo PASS | sshfs UNAME@URL: /path/goes/here -o password_stdin
도움이 되었습니까?

해결책

This turned out to be a configuration problem.

In /etc/fuse.conf I uncommented user_allow_other

Then mounted with this command

echo PASS | sshfs UNAME@URL: /path/goes/here -o password_stdin,allow_other

Normal file/folder checking/reading functions will then work fine

다른 팁

The path should be a string, so:

is_dir("/path/to/the/mount/folder");

Also, if it's unix based I always forget that it's case sensitive :P

You can use:

$path = "/path/to/the/folder";
$name_of_files = glob($path, "*.*");
foreach($name_of_file as $filename)
{
echo $filename;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top