From 35a1102c0b2854ae7903fb82ac68cadd23ba02f5 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 7 May 2017 13:25:43 -0500 Subject: [PATCH] SFTP: fix put() with php://input as source --- phpseclib/Net/SFTP.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 837f2566..40c97daf 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1973,7 +1973,14 @@ class Net_SFTP extends Net_SSH2 break; case is_resource($data): $mode = $mode & ~NET_SFTP_LOCAL_FILE; - $fp = $data; + $info = stream_get_meta_data($data); + if ($info['wrapper_type'] == 'PHP' && $info['stream_type'] == 'Input') { + $fp = fopen('php://memory', 'w+'); + stream_copy_to_stream($data, $fp); + rewind($fp); + } else { + $fp = $data; + } break; case $mode & NET_SFTP_LOCAL_FILE: if (!is_file($data)) {