问题
I want to copy files from a remote directory. But I don't know how to write its UNC. I can use file://Server/Production/Images to open the directory in a browser, but it can't work if I just use this path in my PHP script.
$origin = "file://Sever/Prodution/Images";
$file = scandir($origin);
The rusult is : Warning: scandir(): remote host file access not supported
I have run my wampsever as an administrator, so I assume it can access to remote sever.
回答1:
Without doing any research, I am not sure that 'file://' is a proper protocol to use in a server environment. If you are testing remote file access but are wanting to access files on the local server, you could use http://localhost/path/to/file
or http://127.0.0.1/path/to/file
. You will also need to make sure that the file is with a 'web accessible' directory on your machine. For example, if your wamp stack's webroot is C:\programs\wamp\apache\html\ and the file you are trying to access is located in C:\Sever\Prodution\Images then the file will not be accessible. Make Sense?
来源:https://stackoverflow.com/questions/19012392/how-to-access-a-remote-directory-and-copy-files-in-php