public function uploadFile($pathFrom, $pathTo)
    {
        if ( ! $localStream = @fopen($pathFrom, 'r')) {

            throw new SftpLocalFileException("Unable to open local file: '{$pathFrom}'.");
        }

        if ( ! $remoteStream = @fopen("ssh2.sftp://{$this->ftpConnection}/{$pathTo}", 'w')) {

            throw new SftpRemoteFileException("Unable to open remote: '{$pathTo}'.");
        }

        // write from our remote stream to our local stream
        $buffer       = stream_get_contents($localStream);
        $bytesWritten = strlen($buffer);

        if (fwrite($remoteStream, $buffer) === false) {

            throw new SftpLocalFileException("Unable to write to remote file: '{$pathTo}'.");
        }

        fclose($localStream);
        fclose($remoteStream);

        event( new SshFileUploaded(basename($pathFrom), $pathTo, $bytesWritten) );

        return $bytesWritten;
    }
public function uploadFile($pathFrom, $pathTo)
    {
        if ( ! $localStream = @fopen($pathFrom, 'r')) {

            throw new SftpLocalFileException("Unable to open local file: '{$pathFrom}'.");
        }

        if ( ! $remoteStream = @fopen("ssh2.sftp://{$this->ftpConnection}/{$pathTo}", 'w')) {

            throw new SftpRemoteFileException("Unable to open remote: '{$pathTo}'.");
        }

        // write from our remote stream to our local stream
        $buffer       = stream_get_contents($localStream);
        $bytesWritten = strlen($buffer);

        if (fwrite($remoteStream, $buffer) === false) {

            throw new SftpLocalFileException("Unable to write to remote file: '{$pathTo}'.");
        }

        fclose($localStream);
        fclose($remoteStream);

        event( new SshFileUploaded(basename($pathFrom), $pathTo, $bytesWritten) );

        return $bytesWritten;
    }
public function uploadFile ( $ pathFrom , $ pathTo ) { if ( ! $ localStream = @ fopen ( $ pathFrom , 'r' ) ) { throw new SftpLocalFileException ( "Unable to open local file: '{$pathFrom}'." ) ; } if ( ! $ remoteStream = @ fopen ( "ssh2.sftp://{$this->ftpConnection}/{$pathTo}" , 'w' ) ) { throw new SftpRemoteFileException ( "Unable to open remote: '{$pathTo}'." ) ; } // write from our remote stream to our local stream $ buffer = stream_get_contents ( $ localStream ) ; $ bytesWritten = strlen ( $ buffer ) ; if ( fwrite ( $ remoteStream , $ buffer ) === false ) { throw new SftpLocalFileException ( "Unable to write to remote file: '{$pathTo}'." ) ; } fclose ( $ localStream ) ; fclose ( $ remoteStream ) ; event ( new SshFileUploaded ( basename ( $ pathFrom ) , $ pathTo , $ bytesWritten ) ) ; return $ bytesWritten ; }
Uploads files over SFTP

@param string $pathFrom  path for file to upload
@param string $pathTo    where to store the files
@return bool
@throws SftpLocalFileException
@throws SftpRemoteFileException
Uploads files over SFTP