简体   繁体   中英

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.

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.

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.

My recommendation: use phpseclib, a pure PHP SSH implementation , and post the logs. 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();
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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