I am wamp environment, how to let PHP opendir function can accept relative path?

Source: Internet
Author: User
Keywords Php wamp
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.