duanmen1887 2013-05-27 06:53 采纳率: 0%
浏览 76

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

I have to establish connection with Samba server from my php script in order to download some files into my local server.

Actually its first time I have heard of something like Samba so I Tried to look for a opensource code that I could make use of.

Here it is what I have found: First class - smbclient.php and I tried code posted on the page:


require_once ('smbclient.php');

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

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


Adjusting it into my needs ( server, user, password), all i got is

Failed to retrieve file: 
Fatal error: Call to undefined method smbclient::get_last_stdout() 

Then I found out about smbwebclient.php project which looks awesome and can be found here.

And this class looks good but the problem is that I have no idea how to use it. Can anyone post it example connection or link to tutorial?

  • 写回答

2条回答 默认 最新

  • doutuosai3504 2013-11-17 05:33

    To get files from a samba server, you can try to use a smb wrapper, like the one here but changing the deprecated splits with explodes. Then you can include your php file using this code:

    include( 'smb://user:password@server/folder/file.php');
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
  • douleng0794 2015-01-09 08:31

    Reviving old thread but I think I found the solution, the code must have changed since the pot was made on the blog:

    print join ("
    ", $smbc->get_last_stdout());

    should now be

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



  • ¥15 AD20 PCB板步线 这个要怎么步啊
  • ¥50 关于《奇迹世界》1.5版本,数据修改
  • ¥15 请问这个问题如何解决(关键词-File)
  • ¥50 visual studio 2022和EasyX图形化界面
  • ¥15 找一下报错原因,纠正一下
  • ¥50 Cox回归模型Nomogram图制作报错
  • ¥20 SQL如何查询多级用户的数据
  • ¥15 给车牌识别代码加一个识别轮廓长宽比的代码
  • ¥30 商品价格预测的transformer模型优化
  • ¥15 SQL中的图片,无法传回php到前端。没有任何报错。