doucang2831 2019-02-14 03:48
浏览 185

如何将文件从服务器发送到另一台服务器,服务器没有22端口

I want to trasnfer my files on server to another server with port no 220 and SFTP protocol. When I execute following code, my connection to that sever is getting established with correct username and password, but files are not getting transfered on destination.

My local server is Azure and destination is windows server. Kindly suggest.

This is my code I am trying with:

<?php
   $localFile='/filepath/file1.txt';
   $remoteFile='/remote_server_files/file1.txt';

   $host = "hostname";
   $port = 220;//Here that server is open with 220 port
   $user = "username";
   $pass = "password";

   echo "<pre>result of connection----".$connection = ssh2_connect($host, $port);
   ssh2_auth_password($connection, $user, $pass);
   $sftp = ssh2_sftp($connection);

   $stream = fopen("ssh2.sftp://$sftp$remoteFile", 'w');
   $file = file_get_contents($localFile);
   echo "<br>result of file write----".fwrite($stream, $file);
   fclose($stream);
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条