我必須建立與我的php
腳本中的Samba
服務器的連接,才能將一些文件下載到本地服務器。samba web客戶端 - 在php腳本中建立連接
其實它第一次聽說Samba
之類的東西,所以我試圖尋找一個我可以利用的開源代碼。
這是我發現:First class - smbclient.php,我試圖張貼在網頁代碼:
<?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.";
}
?>
它調整到我的需要(服務器,用戶名,密碼),我的一切是
Failed to retrieve file:
Fatal error: Call to undefined method smbclient::get_last_stdout()
然後我找到了約smbwebclient.php
項目,看起來很棒,可以找到here。
這個類看起來不錯,但問題是我不知道如何使用它。任何人都可以發佈示例連接或鏈接到教程?
對不起,跳上這樣老的回答,我用你鏈接的類和我連接到我的共享,但是當我使用的file_get_contents一個文件,我得到的錯誤'url_stat( ):dir失敗了r路徑'。有任何想法嗎? –