Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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:

<?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.";
}

?>

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?

share|improve this question
add comment

1 Answer

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_once('smb.php');
include( 'smb://user:password@server/folder/file.php');
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.