我在 Windows 7 上有 php,我正在尝试连接到 Linux 上的 Samba 共享文件夹,但没有成功。
我正在使用这段代码:
// Map the drive
system('net use Y: "\\\\linuxIPaddress\Shared_folder password /user:username /persistent:no>nul 2>&1');
// Open the directory
$dir = "Y:/TMP";
if (is_dir($dir)) {
if (opendir($dir)) {
print "able to access directory tree.";
}
} else {
print "not access tree.";
}
最佳答案
我找到了使用此代码连接的解决方案
$sharename = '\\\\LinuxIPAddress\Shared_folder';
$username = 'username';
$password = 'password';
$letter = 'Z:';
if (!is_dir($letter . "/TMP")) {
$WshNetwork = new COM("WScript.Network");
$WshNetwork->MapNetworkDrive($letter, $sharename, FALSE, $username, $password);
}
工作完美
关于php - 我正在尝试使用 php 从 Windows 连接到 Linux 上的 Samba 共享文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17415530/