Problem description: Requirement: if you do not want to expose local information, you can use the relative path for the opendir () function. My homework: I searched for a method to map local resources to a network driver using the netuse command of the system command line. {Code...} and such {code...} still have doubts... Problem description:
Requirement: If you want to avoid exposing local information, you can use the relative path for the opendir () function.
My homework: I searched for a method to map local resources to a network driver using the net use command of the system command line.
// 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")
Also
system('net use K: \\192.168.10.10\pictures /user:username password /persistent:no');$share = opendir('\\\\192.168.10.10\\pictures);
Still have questions:
I still have a lot to understand about this method, so that I have never successfully started this service.
1. What is $ letter? The system prompts that I can only enter one character, otherwise it is not standard.
2 $ location required? In the future, if an independent host server is migrated, $ location should be reserved?
3. What is the account password? I am a local server with the address 127.0.0.1 or localhost. I have never set an account or password, but this is required.
I have no clue. Please give me a detailed answer.
Reply content:
Problem description:
Requirement: If you want to avoid exposing local information, you can use the relative path for the opendir () function.
My homework: I searched for a method to map local resources to a network driver using the net use command of the system command line.
// 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")
Also
system('net use K: \\192.168.10.10\pictures /user:username password /persistent:no');$share = opendir('\\\\192.168.10.10\\pictures);
Still have questions:
I still have a lot to understand about this method, so that I have never successfully started this service.
1. What is $ letter? The system prompts that I can only enter one character, otherwise it is not standard.
2 $ location required? In the future, if an independent host server is migrated, $ location should be reserved?
3. What is the account password? I am a local server with the address 127.0.0.1 or localhost. I have never set an account or password, but this is required.
I have no clue. Please give me a detailed answer.
This is the SMB shared directory (that is, windows file and directory sharing). Here $ letter is the drive letter of Windows. You can enable the Guest account, which means that the guest password is not set as an empty string.
If you are worried about different deployed servers, you can write the IP address and path prefix to the configuration file.