- function put_contents($file, $contents, $type = '' ) {
- $file = ltrim($file, '/');
- return file_put_contents('ssh2.sftp://' . $this->sftp_link .'/' . $file, $contents);
+ /**
+ * @param string $file
+ * @param string $contents
+ * @param bool|int $mode
+ * @return bool
+ */
+ public function put_contents($file, $contents, $mode = false ) {
+ $ret = file_put_contents( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ), $contents );
+
+ if ( $ret !== strlen( $contents ) )
+ return false;
+
+ $this->chmod($file, $mode);
+
+ return true;