简体   繁体   English

使用ssh2_scp_send进行JPG文件传输时出现问题

[英]Issue with JPG file transfer with ssh2_scp_send

We are sending the image files from one server to another. 我们正在将图像文件从一台服务器发送到另一台服务器。 For this we use ssh2 library of PHP. 为此,我们使用PHP的ssh2库。

When send the png images, it will work fine but when send the jpeg or any txt file then it create the file on server but file size is 0 kb. 当发送png图像时,它将正常工作,但是当发送jpeg或任何txt文件时,它将在服务器上创建文件,但文件大小为0 kb。

Anyone have any idea about this issue? 有人对这个问题有任何想法吗?

Could be a lack of permissions? 可能是缺少权限? The SSH server may be sending error messages back but without knowing what they are it'd be hard to figure out what your issue is. SSH服务器可能正在发回错误消息,但是不知道它们是什么,很难弄清问题所在。

My recommendation: use phpseclib, a pure PHP SSH implementation , and post the logs. 我的建议:使用phpseclib(纯PHP SSH实现 )并发布日志。 ie. 即。

<?php
include('Net/SFTP.php');

define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX);

$sftp = new Net_SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

// puts a three-byte file named filename.remote on the SFTP server
$sftp->put('filename.remote', 'xxx');

echo $sftp->getSFTPLog();
?>

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

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