2013-10-09 99 views
1

我可以用同一臺計算機上的文件從一個文件夾傳輸到另一個文件夾。通過SFTP將文件從本地Linux服務器傳輸到遠程Linux服務器

$file = 'pdf.pdf'; 
$source_path = 'source/'; 
$target_path = 'target/'; 

if (! copy($source_path . $file, $target_path . $file)) 
{ 
    exit('Failed to copy ' . $source_path . $file); 
} 

echo $source_path . $file . ' file copied to ' . $target_path . $file; 

我想將它傳輸到使用SFTP-SSH的遠程Linux服務器上,我該怎麼做呢?如果有人問,我發現了很多例子來理解使用cURL(),ftp_get(),stream_copy_to_stream(),ssh2_sftp(),scp()的邏輯,但是由於之前從未做過,所以未能實現它。

注意:我的設置下面的FileZilla工作正常。

target host: https://192.168.32.1/test_folder/ 
target host: https://mysite.site.com/test_folder/ 
protocol: SFTP-SSH 
port: 2281 
username: myusername 
password: mypassword 

感謝

回答

相關問題