Jump to content

I'm trying to connect from Windows to Samba Shared folder on Linux using php


mija

Recommended Posts

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

i found solution for connection using this code

$sharename = '\\\\LinuxIPAddress\Shared_folder';
$username = 'username';
$password = 'password';
$letter = 'Z:';    

if (!is_dir($letter . "/TMP")) {
if (!opendir($letter . "/TMP")) {
    $WshNetwork = new COM("WScript.Network");
    $WshNetwork->MapNetworkDrive($letter, $sharename, FALSE, $username, $password);
}
}

and is working perfect

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.