ssh2-sftp

PHP 7 SSH2.SFTP stat() bug work around

风流意气都作罢 提交于 2021-01-27 06:19:24
问题 I have an app the uses an SFTP connection to download files. It was working correctly in PHP 5.6, not so much in PHP 7. The error I get is as follows: PHP Warning: filesize(): stat failed for ssh2.sftp ... My code is as follows: public function retrieveFiles($downloadTargetFolder,$remoteFolder = '.') { $fileCount = 0; echo "\nSftpFetcher retrieveFiles\n"; $con = ssh2_connect($this->host,$this->port) or die("Couldn't connect\n"); if($this->pubKeyFile){ $isAuth = ssh2_auth_pubkey_file($con,

How to increase the performance of a file upload using native sftp functions and fwrite in PHP

痞子三分冷 提交于 2020-11-29 03:48:29
问题 Hi I am using the following code to upload a huge file (500MB) to a sftp server. <?php $connection = ssh2_connect($this->host, $this->port, null); $sftp = ssh2_sftp($connection); $connection_string = ((int) $sftp) . $remotePath . $remoteFilename; $stream = fopen('ssh2.sftp://' . $connection_string, 'w'); $source = fopen($localFilepath, 'r'); if (!$stream) { throw new Exception('Could not create file: ' . $connection_string); } while (!feof($source)) { // Chunk size 32 MB if (fwrite($stream,

Why does SFTP via PHP fail, but succeeds in FileZilla on my Windows 8.1 machine?

邮差的信 提交于 2020-01-24 18:46:04
问题 In PHP, I cannot even get the SFTP connection to work. I have tried to use the native SFTP functionality (ssh_connect), and it fails to connect. I have also tried to use phpseclib, but it fails as well. Neither of my aforementioned attempts have provided much in the way of log info. The native code: if (!function_exists('ssh2_connect')) { echo "dll not loaded properly"; //never see this, so I know it works return false; } $connection = ssh2_connect('sftp.example.com', 22); ssh2_auth_password(

Not able to call method within another method of the same class JS

只谈情不闲聊 提交于 2019-12-13 16:08:33
问题 I am trying to call method test in method connect of the same class. But all I am getting is "Uncaught Type Error: Cannot read property 'test' of undefined". How do I access any variables inside of sftp callback? Why is it so? Here is my code: const SSH2 = require('ssh2').Client; class SshClient { constructor(host, username, password) { this.host = host; this.username = username; this.password = password; this.port = 22; this.client = null; } test(testvar) { console.log(testvar); } connect()

SSH2 in php, wamp,windows

允我心安 提交于 2019-12-12 10:12:52
问题 I have to connect sftp link and have to put data in sftp link. I want to connect sftp link through function ssh2_connect . My trouble is that whenever i am running that function i am getting error Call to undefined function ssh2_connect() . Then I downloaded libssh2.tar.gz and ssh2.tgz but i dont know where to install / put these files. I am using - Windows 7, Wamp server, mysql, php P.O. - If i have to run come commands then please tell also where i have to run that commands. Thanks in

SSH2 for PHP7 MacOS?

自闭症网瘾萝莉.ら 提交于 2019-12-05 16:04:26
When trying to use ssh2_sftp($this->con); PHP 7.1.7 thinks Im looking for a function in the class. After some reading, I found that SSH2 needs to be installed from PECL ( http://php.net/manual/en/wrappers.ssh2.php ) When I went to do that, I got the following error: pecl/ssh2 requires PHP (version >= 4.0.0, version <= 6.0.0), installed version is 7.1.7 No valid packages found install failed Anyone have any ideas on how to get this to run on MacOs 10.13.3 (17D47) with PHP 7.1.7? Thanks in advance! Nigel Atkinson I managed to install php-ssh2 on MacOS High Sierra. First I had to install libssh2