Problem Description:
Requirement: You want to not expose local information, so you want the Opendir () function to accept relative paths.
Homework: searched for a net use directive that uses the system command line to map local resources to a network-driven approach.
// Define the parameters for the shell command$location = "\\servername\sharename";$user = "USERNAME";$pass = "PASSWORD";$letter = "Z";// Map the drivesystem("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");// Open the directory$dir = opendir($letter.":/an/example/path")
And there's this.
system('net use K: \\192.168.10.10\pictures /user:username password /persistent:no');$share = opendir('\\\\192.168.10.10\\pictures);
There are still questions:
I still have a lot of things I don't know about this approach, and I've never successfully opened this service.
1 What is this $letter? The system prompts me to fill only one character, otherwise not canonical.
2$location How to fill in? And in the future if you move to an independent host server, $location How to fill it?
3 What is the account password? I am a local server, the address is 127.0.0.1, or localhost, never set an account password, but this is required.
I have no clue, but also ask you to help detailed answers.
Reply content:
Problem Description:
Requirement: You want to not expose local information, so you want the Opendir () function to accept relative paths.
Homework: searched for a net use directive that uses the system command line to map local resources to a network-driven approach.
// Define the parameters for the shell command$location = "\\servername\sharename";$user = "USERNAME";$pass = "PASSWORD";$letter = "Z";// Map the drivesystem("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");// Open the directory$dir = opendir($letter.":/an/example/path")
And there's this.
system('net use K: \\192.168.10.10\pictures /user:username password /persistent:no');$share = opendir('\\\\192.168.10.10\\pictures);
There are still questions:
I still have a lot of things I don't know about this approach, and I've never successfully opened this service.
1 What is this $letter? The system prompts me to fill only one character, otherwise not canonical.
2$location How to fill in? And in the future if you move to an independent host server, $location How to fill it?
3 What is the account password? I am a local server, the address is 127.0.0.1, or localhost, never set an account password, but this is required.
I have no clue, but also ask you to help detailed answers.
This is the SMB shared directory (that is, Windows file, directory sharing), here $letter is the Windows drive letter, can open the Guest account, the account is the guest password is not set is an empty string.
If you are concerned about a different server scenario, you can write the IP, path prefix section to the configuration file.