Make this SFTP file transfer all day really drunk, from SFTP installation, to PHP ssh2 extension installation, and finally to the PHP application ssh2 to upload files; Finally, there's no end.
Failure Creating remote file: (NULL) This error has been reported! Online can search the basic find a time does not work, at first thought laravel frame problem, later written as a native PHP script is also this error, fine! Very good really do not have;
Workaround:
Use league/flysystem-sftp This while the plug-in to run SFTP file transfer, in the composer download relies on the use of the method is also very simple
UseLeague\flysystem\sftp\sftpadapter;UseLeague\flysystem\filesystem;$adapter=NewSftpadapter ([ ' Host‘=' example.com‘, ' Port‘=02n ' Username‘=' Username‘, ' Password‘=' Password‘, ' Privatekey‘= ' Path/to/or/contents/of/privatekey ' Root ' = > '/path/to/root " "Timeout => 10 , ' Directoryperm ' = = 0755); $filesystem = New filesystem ( $adapter);
//After getting to object
1. $filesystem->put (' Remote file path ', ' content ');
2. $filesystem->putstream (' Remote file path ', ' file handle ');//Get Handle by fopen
Personal Memo:
SSH is installed in the Linux/ubuntu system with SFTP, and if it is not configured, it will not connect to the remote
Unable to negotiate with 113.105.66.197 Port 8521:no matching host key type found. Their OFFER:SSH-DSS
Couldn ' t read packet:connection reset by peer
Workaround:
Add config file under/personal directory/.ssh/
VI/Personal directory/.ssh/config
Hostkeyalgorithms +ssh-dss Add this phrase save exit and try to connect the SFTP
PHP Uploading files using SFTP