public function upload($local, $remote)
{
$this->checkConnection();
$remote = str_replace(DIRECTORY_SEPARATOR, '/', $remote);
$dir = str_replace(DIRECTORY_SEPARATOR, '/', dirname($remote));
if (!isset($this->directories[$dir])) {
$this->sftp->mkdir($dir, -1, true);
$this->directories[$dir] = true;
}
if (!$this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) {
throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n"));
}
}