doubi7496 2013-07-02 00:10 采纳率: 0%
浏览 76
已采纳

我正在尝试使用php从Linux连接到Linux上的Samba Shared文件夹

I have php on Windows 7 and I'm trying to connect to Samba Shared folder on Linux but no success.

I'm using this code:

// 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.";
}
  • 写回答

2条回答 默认 最新

  • doucai7294 2013-07-02 13:05
    关注

    i found solution for connection using this code

    $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);
    }
    

    and is working perfect

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?