Guest User

Untitled

a guest
Sep 6th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. $ftpHost = 'ftp.site.in';
  2. $ftpUsername = 'username';
  3. $ftpPassword = '******';
  4.  
  5. // open an FTP connection
  6. $connId = ftp_connect($ftpHost) or die("Couldn't connect to $ftpHost");
  7.  
  8. // try to login
  9. if(@ftp_login($connId, $ftpUsername, $ftpPassword)){
  10. echo "Connected as $ftpUsername@$ftpHost";
  11. }else{
  12. echo "Couldn't connect as $ftpUsername";
  13. }
  14. $contents = ftp_nlist($connId, ".");
  15. var_dump($contents);
  16. // local & server file path
  17. $localFilePath = 'csv';
  18. $remoteFilePath = 'public_html/csvfiles/';
  19. // try to download a file from server
  20. if(ftp_get($connId, $localFilePath, $remoteFilePath, FTP_BINARY)){
  21. echo "File transfer successful - $localFilePath";
  22. }else{
  23. echo "There was an error while downloading $localFilePath";
  24. }
Add Comment
Please, Sign In to add comment