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->session->getSftp()->mkdir($dir, -1, true);
$this->directories[$dir] = true;
}
if ($this->session->getSftp()->send($local, $remote) === false) {
throw new \RuntimeException('Can not upload file.');
}
}