Created
August 20, 2008 17:27
-
-
Save mrinterweb/6409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function mySFTP($source_file, $destination_file){ | |
if(!$this->connection) return false; | |
$sftp = ssh2_sftp($this->connection); | |
$sftpStream = fopen("ssh2.sftp://{$sftp}{$destination_file}", 'wb'); | |
if($sftpStream) stream_set_blocking($sftpStream, true); | |
else return false; | |
try { | |
if (!$sftpStream) | |
throw new Exception("Could not open remote file: $destination_file"); | |
$data_to_send = @file_get_contents($source_file); | |
if ($data_to_send === false) | |
throw new Exception("Could not open local file: $source_file."); | |
if (@fwrite($sftpStream, $data_to_send) === false) | |
throw new Exception("Could not send data from file: $source_file."); | |
} catch (Exception $e) { | |
$this->logError('Exception: ' . $e->getMessage()); | |
} | |
fclose($sftpStream); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment