问题
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
回答1:
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
回答2:
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
回答3:
You can use:
$path = "/path/to/the/folder";
$name_of_files = glob($path, "*.*");
foreach($name_of_file as $filename)
{
echo $filename;
}
来源:https://stackoverflow.com/questions/12620712/how-do-i-check-whether-a-fuse-folder-is-present