简体   繁体   English

在 Mac 上通过 PHP 中的 scandir 访问外部 NAS /卷

[英]Access External NAS /Volume via scandir in PHP on Mac

I've done a bunch of research on this one and there are very different answers.我已经对此进行了大量研究,并且有非常不同的答案。 I can't get confident that I won't mess up my Apache settings or cause me not to be able to get to the Volume from Mac Finder after making changes.我不能确信我不会弄乱我的 Apache 设置或导致我在进行更改后无法从 Mac Finder 访问卷。

Has anyone done this recently that can walk me through the steps to get my PHP/Apache local site on Mac read from an external NAS /Volume.最近有没有人这样做,可以引导我完成从外部 NAS /Volume 读取 Mac 上的 PHP/Apache 本地站点的步骤。 I want to use scandir to read the files list.我想使用scandir来读取文件列表。

The PHP code is simple, and works on my local disk, but not on a /Volume PHP 代码很简单,适用于我的本地磁盘,但不适用于 /Volume

$path = '/Volumes/Nas/Files';
$files = scandir($path);
print_r($files);

Getting error scandir(/Volumes/Nas/Files): failed to open dir: Permission denied获取错误scandir(/Volumes/Nas/Files): failed to open dir: Permission denied

Thanks.谢谢。

Get user name running the php script, see https://www.php.net/manual/en/function.get-current-user.php , and then fix file permissions for that user.获取运行 php 脚本的用户名,请参阅https://www.php.net/manual/en/function.get-current-user.php ,然后为该用户修复文件权限。

If absolutely needed, you can use bindfs to translate the permissions for your script/user.如果绝对需要,您可以使用 bindfs 为您的脚本/用户转换权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM