php - Upload files via SFTP with phpseclib -
i uploading csv files via sftp using phpseclib class. following:
include('vendor/autoload.php'); use phpseclib\crypt\rsa; use phpseclib\net\sftp; $sftp = new sftp($sftpserverhost); $key = new rsa(); $key->setpassword($sftpkeypassword); $key->loadkey(file_get_contents($sftpkey)); if (!$sftp->login($sftpusername, $key)) { throw new exception('login failed'); }else{ $sftp->chdir('upload'); $sftp->put($filename, $output); }
$output - content of csv file. if content less ~40 lines file uploading no issues though if content >40 lines script hangs while outputs several lines of error:
php notice: uninitialized string offset: 0 in /vendor/phpseclib/phpseclib/phpseclib/net/ssh2.php on line 3167 php notice: connection closed prematurely in /vendor/phpseclib/phpseclib/phpseclib/net/ssh2.php on line 3025 php notice: connection closed server in /vendor/phpseclib/phpseclib/phpseclib/net/ssh2.php on line 3373 php notice: expected ssh_fxp_status in /vendor/phpseclib/phpseclib/phpseclib/net/sftp.php on line 2027 php notice: connection closed prematurely in /vendor/phpseclib/phpseclib/phpseclib/net/ssh2.php on line 3599
as result file not uploaded. suggestions how fix it?
Comments
Post a Comment