[英]Trying to access a windows shared folder through php (laravel) on a linux machine using scandir
Good afternoon everyone, I'm trying to access a windows shared folder on the same network through php (laravel) using the scandir method. 大家下午好,我正在尝试使用scandir方法通过php(laravel)访问同一网络上的Windows共享文件夹。 here is some sample code
这是一些示例代码
$dir = '\\\\192.168.1.18\\Data';
$files = scandir($dir);
return $files;
I've tried different ways to type the server address (\\192.168.1.18\\Data and so forth). 我尝试了不同的方式来键入服务器地址(\\ 192.168.1.18 \\ Data等)。
I get a scandir(\\\\192.168.1.18\\Data): failed to open dir: No such file or directory
我得到一个
scandir(\\\\192.168.1.18\\Data): failed to open dir: No such file or directory
thanks in advance 提前致谢
you can check if it's a problem with the shared folder or with the PHP by replacing scandir with this simple linux command: 您可以使用以下简单的linux命令替换scandir,以检查共享文件夹或PHP是否存在问题:
exec("ls \\\\192.168.1.18\\Data",$result);
print_r($result);
if you will get an error No such file or directory so you have problem with the shared folder. 如果出现错误没有这样的文件或目录 ,则共享文件夹有问题。
I think this question might help you. 我认为这个问题可能对您有帮助。 It suggests mounting the Windows share in Linux.
建议在Linux中安装Windows共享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.