小编Eri*_*man的帖子

使用SFTP上传文件

我已成功通过ftp上传文件,但我现在需要通过SFTP完成.我可以成功连接到远程服务器,创建文件并写入,但我无法将现有文件从本地服务器上传到远程服务器.ftp_put是否没有使用sftp连接触发?

我的代码用来写一个文件:

//Send file via sftp to server

$strServer = "*****";
$strServerPort = "****";
$strServerUsername = "*****";
$strServerPassword = "*****";
$csv_filename = "Test_File.csv";

//connect to server
$resConnection = ssh2_connect($strServer, $strServerPort);

if(ssh2_auth_password($resConnection, $strServerUsername, $strServerPassword)){
    //Initialize SFTP subsystem

    echo "connected";
    $resSFTP = ssh2_sftp($resConnection);    

    $resFile = fopen("ssh2.sftp://{$resSFTP}/".$csv_filename, 'w');
    fwrite($resFile, "Testing");
    fclose($resFile);                   

}else{
    echo "Unable to authenticate on server";
}
Run Code Online (Sandbox Code Playgroud)

有没有人在抓取本地文件并通过sftp上面的方法上传?一个例子将不胜感激.

谢谢

php sftp

33
推荐指数
3
解决办法
7万
查看次数

如何在函数中使用数组指针?

我必须编写一个程序,它具有一个函数,该函数对数组中的所有正数进行求和,但使用函数参数数组作为指针.当我尝试调用sum函数时,在main函数中出现问题.这是我的源代码:

#include <stdio.h>
#include <conio.h>
int posit(int *x[], int n){
  int s=0;
  for(int i=0; i<n; i++){
    if(*x[i]>0){
      s=s+*x[i];
    }
  }
  return s;
}
int main(){
  int k;
  scanf("%d",&k);
  int a[k];
  for(int i=0; i<k; i++){
    scanf("%d",&a[i]);
  }
  int b=posit(&a,k);
  printf("%d\n", b);
  getch();
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

c arrays pointers

1
推荐指数
1
解决办法
120
查看次数

标签 统计

arrays ×1

c ×1

php ×1

pointers ×1

sftp ×1