将文件从一个DV服务器复制到另一个PHP服务器
但是,使用php在本地和远程服务器之间复制文件或文件夹的最佳和最简单的方法是什么?这些文件位于web文件夹上方,因此我需要使用路径而不是URL。我会使用PHP内置的FTP函数来完成将文件从一个DV服务器复制到另一个PHP服务器,php,file-io,remote-server,Php,File Io,Remote Server,但是,使用php在本地和远程服务器之间复制文件或文件夹的最佳和最简单的方法是什么?这些文件位于web文件夹上方,因此我需要使用路径而不是URL。我会使用PHP内置的FTP函数来完成 编辑:啊,你想要安全。这就是我将要使用的:我制作了这个函数,希望它能为您从ftp复制文件起作用: $ftpConnection=连接,例如ftp_连接(1.0.0.1)。 $path=ftp路径。 $destination=本地文件 function ftpRecursiveFileListing($ftpConne
编辑:啊,你想要安全。这就是我将要使用的:我制作了这个函数,希望它能为您从ftp复制文件起作用: $ftpConnection=连接,例如ftp_连接(1.0.0.1)。 $path=ftp路径。 $destination=本地文件
function ftpRecursiveFileListing($ftpConnection, $path, $destination) {
$contents = ftp_nlist($ftpConnection, $path);
foreach ($contents as $currentFile) {
if (strpos($currentFile, '.') === false) {
$dir = basename($currentFile);
echo "<br> <b> Directorio </b>" . $dir;
mkdir($destination . "/" . $dir);
ftpRecursiveFileListing($ftpConnection, $currentFile, $destination . "/" . $dir);
} else {
$file = basename($currentFile);
echo '<br> <b>archivo </b>' . $file;
echo '<br> <b>path </b>' . $path;
echo '<br> <b>completo </b>' . $path . "/" . $file;
ftp_get($ftpConnection, $destination . '/' . $file, $path . '/' . $file, FTP_BINARY);
}
}
}
函数ftpRecursiveFileListing($ftpConnection,$path,$destination){
$contents=ftp\u nlist($ftpConnection,$path);
foreach($currentFile形式的内容){
if(strpos($currentFile,'.')==false){
$dir=basename($currentFile);
echo“
Directorio”。$dir;
mkdir($destination.“/”$dir);
ftpRecursiveFileListing($ftpConnection,$currentFile,$destination.“/”$dir);
}否则{
$file=basename($currentFile);
回显'
archivo'.$文件;
回显'
路径'.$path;
回显“
completo.”路径“/”$文件;
ftp_get($ftpConnection,$destination.'/'.$file,$path.'/'.$file,ftp_二进制文件);
}
}
}
对不起,我指的是专用虚拟服务器。安全吗?我该如何使用SFTP?太好了。正是我要找的!谢谢