How to access a remote directory and copy files in PHP

筅森魡賤 提交于 2019-12-10 18:38:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!