简体   繁体   English

ssh2_scp_send 文件没有被复制,没有错误

[英]ssh2_scp_send file is not copied, no errors

Though connection works ssh2_scp_send is not copying file (pdf).虽然连接有效ssh2_scp_send不是复制文件 (pdf)。

To check connection I checked if source file is existent and I also tested and used successful:为了检查连接,我检查了源文件是否存在,我也测试并成功使用:
- ssh2_sftp_mkdir - ssh2_sftp_mkdir
- ssh2_scp_recv - ssh2_scp_recv

Here is my php code:这是我的php代码:

$my_sftp = parse_ini_file(config/sftp.ini.php');
$open_file = fopen($contract_pdf_path.$contract_pdf_name, 'r');

$destination = $my_sftp['sftp_root_to_dir'].'auftrag/'.$contract_pdf_name;              
$connection = ssh2_connect($my_sftp['sftp_host'], $my_sftp['sftp_port']);
            ssh2_auth_password($connection,$my_sftp['sftp_user'], $my_sftp['sftp_password']);

$sftp = ssh2_sftp($connection);

$result = ssh2_scp_send($connection, $contract_pdf_path.$contract_pdf_name, $destination, 0644);

I checked $result and got 1, as described I tested successful with other functions.我检查了 $result 并得到了 1,正如我用其他函数测试成功的那样。

Anybody any idea?有人有什么想法吗?

To whom it may concern (or is interested):与谁有关(或感兴趣):
Got some hints on another forum:在另一个论坛上得到了一些提示:

$my_sftp = parse_ini_file('config/sftp.ini.php');
$destination = $my_sftp['sftp_root_to_dir'] . 'auftrag/' . $contract_pdf_name;
$connection = ssh2_connect($my_sftp['sftp_host'], $my_sftp['sftp_port']);
ssh2_auth_password($connection, $my_sftp['sftp_user'], $my_sftp['sftp_password']);
$sftp = ssh2_sftp($connection);
$sftpStream = fopen('ssh2.sftp://'.intval($sftp).$destination, 'w');
fwrite($sftpStream,file_get_contents(realpath( $contract_pdf_path.$contract_pdf_name)));
fclose($sftpStream);

And this one works :-)这一个有效:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM