| @@ 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) === false) { |
|
| 135 | throw new \RuntimeException('Can not upload file.'); |
|
| 136 | } |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * {@inheritdoc} |
|
| @@ 133-148 (lines=16) @@ | ||
| 130 | /** |
|
| 131 | * {@inheritdoc} |
|
| 132 | */ |
|
| 133 | public function upload($local, $remote) |
|
| 134 | { |
|
| 135 | $this->checkConnection(); |
|
| 136 | ||
| 137 | $remote = str_replace(DIRECTORY_SEPARATOR, '/', $remote); |
|
| 138 | $dir = str_replace(DIRECTORY_SEPARATOR, '/', dirname($remote)); |
|
| 139 | ||
| 140 | if (!isset($this->directories[$dir])) { |
|
| 141 | $this->sftp->mkdir($dir, -1, true); |
|
| 142 | $this->directories[$dir] = true; |
|
| 143 | } |
|
| 144 | ||
| 145 | if (!$this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) { |
|
| 146 | throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n")); |
|
| 147 | } |
|
| 148 | } |
|
| 149 | ||
| 150 | /** |
|
| 151 | * {@inheritdoc} |
|