Advertisement
Guest User

Untitled

a guest
May 28th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. // FTP server details
  3. $ftpHost = 'ftp.host.com';
  4. $ftpUsername = 'tutsplanet';
  5. $ftpPassword = 'xxxxxxxxxx';
  6.  
  7. // open an FTP connection
  8. $connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
  9.  
  10. // login to FTP
  11. if(@ftp_login($connId, $ftpUsername, $ftpPassword)){
  12. echo "Connected as $ftpUsername@$ftpHost";
  13. }else{
  14. echo "Couldn't connect as $ftpUsername";
  15. }
  16.  
  17. // local & server file path
  18. $localDirFilePath = 'test1.php';
  19. $remoteDirFilePath = 'public_html/test1.php';
  20.  
  21.  
  22. // downloading the file
  23. if(ftp_get($connId, $localDirFilePath, $remoteDirFilePath, FTP_BINARY)){
  24. echo "File downlaod successful - $localDirFilePath";
  25. }else{
  26. echo "There is an error while downloading $remoteDirFilePath";
  27. }
  28. // close the connection
  29. ftp_close($connId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement