Advertisement
Guest User

Untitled

a guest
Sep 17th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: user
  5. * Date: 14.09.18
  6. * Time: 16:16
  7. */
  8.  
  9. namespace app\commands;
  10.  
  11. use yii\console\Controller;
  12.  
  13.  
  14. class DownloadController extends Controller
  15. {
  16. public function actionDownload()
  17. {
  18. $local_file = __DIR__ . '/modules/sokolov.data.json';
  19. $server_file = 'ftp://box_sokolov@ftp.ucann.ru/sokolov.data.json';
  20. $ftp_server = 'box_sokolov@ftp.ucann.ru';
  21. $ftp_user_name = 'box_sokolov';
  22. $ftp_user_pass = 'ww1zbdx1';
  23. $conn_id = ftp_connect($ftp_server);
  24. if (ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
  25. if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
  26. echo 'Файл сохранен в' . $local_file;
  27. } else {
  28. echo 'Ошибка';
  29. }
  30. }
  31. ftp_close($conn_id);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement