samba web客户端-在php脚本中设置连接

samba web客户端-在php脚本中设置连接,php,samba,Php,Samba,我必须从php脚本与Samba服务器建立连接,以便将一些文件下载到本地服务器 事实上,这是我第一次听说类似于Samba的东西,所以我试图寻找一个我可以利用的开源代码 以下是我的发现:我尝试了页面上发布的代码: <?php require_once ('smbclient.php'); $smbc = new smbclient ('//10.0.1.1/example', 'exampleuser', 'examplepassword'); if (!$smbc->get ('

我必须从
php
脚本与
Samba
服务器建立连接,以便将一些文件下载到本地服务器

事实上,这是我第一次听说类似于
Samba
的东西,所以我试图寻找一个我可以利用的开源代码

以下是我的发现:我尝试了页面上发布的代码:

<?php

require_once ('smbclient.php');

$smbc = new smbclient ('//10.0.1.1/example', 'exampleuser', 'examplepassword');

if (!$smbc->get ('path/to/desired/file.txt', '/tmp/localfile.txt'))
{
    print "Failed to retrieve file:\n";
    print join ("\n", $smbc->get_last_stdout());
}
else
{
    print "Transferred file successfully.";
}

?>
然后我发现了
smbwebclient.php
project,它看起来很棒,可以找到


这门课看起来不错,但问题是我不知道如何使用它。有人可以发布示例连接或链接到教程吗?

要从samba服务器获取文件,您可以尝试使用smb包装器,就像使用explodes更改不推荐的拆分一样。然后,您可以使用以下代码包含php文件:

include_once('smb.php');
include( 'smb://user:password@server/folder/file.php');

恢复旧线程,但我认为我找到了解决方案,自从在博客上制作了pot之后,代码一定发生了变化:

print join ("\n", $smbc->get_last_stdout());
现在应该是

print join ("\n", $smbc->get_last_cmd_stdout());

很抱歉跳到这样的旧答案上,我正在使用您链接的类并连接到我的共享,但是当我为文件使用file\u get\u内容时,我得到错误
url\u stat():dir路径失败
。有什么想法吗?
print join ("\n", $smbc->get_last_cmd_stdout());