Jump to content

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

Go to solution Solved by 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.";

Link to comment
Share on other sites

  • Solution

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.