Advertisement
Guest User

Untitled

a guest
May 28th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2. // FTP server details
  3. $ftpHost = 'ftp.host.com';
  4. $ftpUsername = 'tutsplanet';
  5. $ftpPassword = 'xxxxxxx';
  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 = 'test.php';
  19. $remoteDirFilePath = 'public_html/test.php';
  20.  
  21. // Uploading a file
  22. if(ftp_put($connId, $remoteDirFilePath, $localDirFilePath, FTP_ASCII)){
  23. echo "File transfer successful - $localDirFilePath";
  24. }else{
  25. echo "There is an error while uploading $remoteDirFilePath";
  26. }
  27.  
  28. // close the FTP connection
  29. ftp_close($connId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement