| @@ 123-138 (lines=16) @@ | ||
| 120 | /** |
|
| 121 | * {@inheritdoc} |
|
| 122 | */ |
|
| 123 | public function upload($local, $remote) |
|
| 124 | { |
|
| 125 | $this->checkConnection(); |
|
| 126 | ||
| 127 | $remote = str_replace(DIRECTORY_SEPARATOR, '/', $remote); |
|
| 128 | $dir = str_replace(DIRECTORY_SEPARATOR, '/', dirname($remote)); |
|
| 129 | ||
| 130 | if (!isset($this->directories[$dir])) { |
|
| 131 | $this->sftp->mkdir($dir, -1, true); |
|
| 132 | $this->directories[$dir] = true; |
|
| 133 | } |
|
| 134 | ||
| 135 | if (!$this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) { |
|
| 136 | throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n")); |
|
| 137 | } |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * {@inheritdoc} |
|
| @@ 122-137 (lines=16) @@ | ||
| 119 | /** |
|
| 120 | * {@inheritdoc} |
|
| 121 | */ |
|
| 122 | public function upload($local, $remote) |
|
| 123 | { |
|
| 124 | $this->checkConnection(); |
|
| 125 | ||
| 126 | $remote = str_replace(DIRECTORY_SEPARATOR, '/', $remote); |
|
| 127 | $dir = str_replace(DIRECTORY_SEPARATOR, '/', dirname($remote)); |
|
| 128 | ||
| 129 | if (!isset($this->directories[$dir])) { |
|
| 130 | $this->session->getSftp()->mkdir($dir, -1, true); |
|
| 131 | $this->directories[$dir] = true; |
|
| 132 | } |
|
| 133 | ||
| 134 | if (!$this->session->getSftp()->send($local, $remote)) { |
|
| 135 | throw new \RuntimeException('Can not upload file.'); |
|
| 136 | } |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * {@inheritdoc} |
|