| @@ 54-62 (lines=9) @@ | ||
| 51 | * @param $localFile |
|
| 52 | * @throws \Exception |
|
| 53 | */ |
|
| 54 | public function copy($remoteFile, $localFile) |
|
| 55 | { |
|
| 56 | $sftp = "ssh2.sftp://$this->sftp"; |
|
| 57 | $data = file_get_contents($sftp . $remoteFile); |
|
| 58 | if (!$data) { |
|
| 59 | throw new \Exception('File can`t be loaded from server'); |
|
| 60 | } |
|
| 61 | file_put_contents($localFile, $data); |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @param $localFile |
|
| @@ 69-76 (lines=8) @@ | ||
| 66 | * @param $remoteFile |
|
| 67 | * @throws \Exception |
|
| 68 | */ |
|
| 69 | public function send($localFile, $remoteFile) |
|
| 70 | { |
|
| 71 | $sftp = "ssh2.sftp://$this->sftp"; |
|
| 72 | $data = file_get_contents($localFile); |
|
| 73 | if (!file_put_contents($sftp . $remoteFile, $data)) { |
|
| 74 | throw new \Exception('File could not be uploaded to server'); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * @param $dir |
|