如何访问远程目录并用PHP复制文件 [英] How to access a remote directory and copy files in PHP
问题描述
$ origin =file:// Sever / Prodution / Images;
$ file = scandir($ origin);
结果是:警告:scandir():不支持远程主机文件访问b
$ b
我已经以管理员身份运行了我的wampsever,因此我认为它可以访问远程服务器。
http://127.0.0.1/path/to/file
。您还需要确保文件在您的计算机上具有网络可访问目录。例如,如果你的wamp栈的webroot是C:\programs\wamp\apache\html\,而你试图访问的文件位于C:\Sever\Prodution\Images那么文件将无法访问。让感觉? 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.
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?
这篇关于如何访问远程目录并用PHP复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!