<?php
$localfile = 'test1.txt';
$fp = fopen ($localfile, "r") or die('Cannot open textfile');
$connection = ssh2_connect('sftp_server_path/folder',22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection) or die ("Cannot connect to server");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"sftp_server_path/folder/test1.txt");
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
if(curl_exec($ch)){
echo 'File was successfully transferred using SFTP';
}else{
echo 'File was unable to be transferred using SFTP';
}
?>
위의 코드를 연결하여 sftp 서버로 전송하면이 코드가 실행되어 "파일이 SFTP를 사용하여 성공적으로 전송되었습니다"라는 메시지가 나타납니다. 하지만 sftp 서버에서 폴더 구조를 볼 때 sftp 서버에서 전송 파일을 볼 수 없습니다. 정확히 내가 뭘해야되는거야?어떻게 SFTP 서버에서 파일에 액세스 할 수 있습니까?
즉, myfolder 권한을 의미합니까? 그것의 777. – user1122910