Advertisement
Guest User

Untitled

a guest
May 1st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. function ftp_copy($source_file, $destination_file)
  4. {
  5. $ftp_server = 'ftp.server.com';
  6. $ftp_user = 'login';
  7. $ftp_password = 'password';
  8.  
  9. $conn_id = ftp_connect($ftp_server);
  10. $login_result = ftp_login($conn_id, $ftp_user, $ftp_password);
  11.  
  12. if((!$conn_id) || (!$login_result))
  13. {
  14. echo "FTP connection has failed!";
  15. echo "Attempted to connect to $ftp_server for user $ftp_user";
  16. }
  17.  
  18. $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
  19. ftp_close($conn_id);
  20.  
  21. if(!$upload)
  22. {
  23. echo "FTP copy has failed!";
  24. return false;
  25. }
  26. else
  27. {
  28. return true;
  29. }
  30. }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement