简体   繁体   中英

Connecting to windows remote share in PHP

I am trying to connect to a directory shared in my network (something like \\remoteserver\\mydir) with php. I tried the function fopen but it tells me that I don't have the permission to connect, so it seems that the function reaches the server but can't access the directory, which was understandable since the function doesn't get credentials in input. I tried also to make the remote directory as network unit (Z:) but the function still doesn't get through. Currently I have two environment where i can test this one is using EasyPhp and the other one is using WAMP.

Does anybody of you have ever get this done?

Thanks in advance Best

Here is someone who explains some of it:

http://us.php.net/manual/en/function.opendir.php#90373

// Define the parameters for the shell command
$location = "\\servername\sharename";
$user = "USERNAME";    
$pass = "PASSWORD";
$letter = "Z";

// Map the drive
system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");

// Open the directory
$dir = opendir($letter.":/an/example/path")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM