note 80671 added to function.ssh2-sftp

From: Date: Mon, 28 Jan 2008 15:58:55 +0000
Subject: note 80671 added to function.ssh2-sftp
Groups: php.notes 
Request: Send a blank email to php-notes+get-135483@lists.php.net to get a copy of this message
The sftp class provided by David Barnes works great. However, if you get errors about fopen and it failing to open a stream, try the fully qualified path on the remote server. For example, if you are uploading a file to /Users/username/Sites/file.txt this may not work: <?php try { $sftp = new SFTPConnection("localhost", 22); $sftp->login("username", "password"); $sftp->uploadFile("/tmp/to_be_sent", "Sites/file.txt"); } catch (Exception $e) { echo $e->getMessage() . "\n"; } ?> but this will: <?php try { $sftp = new SFTPConnection("localhost", 22); $sftp->login("username", "password"); $sftp->uploadFile("/tmp/to_be_sent", "/Users/username/Sites/file.txt"); } catch (Exception $e) { echo $e->getMessage() . "\n"; } ?> Don't assume that since you are connecting as that user that you are starting in its home space. Another possible option is that you need to use http://us.php.net/manual/en/function.ssh2-sftp-mkdir.php first to make the directory if it does not exist already, and then upload the file into it. ---- Server IP: 209.41.74.194 Probable Submitter: 128.123.194.148 ---- Manual Page -- http://www.php.net/manual/en/function.ssh2-sftp.php Edit -- https://master.php.net/note/edit/80671 Del: integrated -- https://master.php.net/note/delete/80671/integrated Del: useless -- https://master.php.net/note/delete/80671/useless Del: bad code -- https://master.php.net/note/delete/80671/bad+code Del: spam -- https://master.php.net/note/delete/80671/spam Del: non-english -- https://master.php.net/note/delete/80671/non-english Del: in docs -- https://master.php.net/note/delete/80671/in+docs Del: other reasons-- https://master.php.net/note/delete/80671 Reject -- https://master.php.net/note/reject/80671 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135483) next »