944,032 Members | Top Members by Rank

Ad:
  • PHP Code Snippet
  • Views: 8313
  • PHP RSS
0

FTP login - upload

by on Mar 25th, 2005
Allows a user to login to an ftp and upload files.
PHP Code Snippet (Toggle Plain Text)
  1. <?php
  2. // set up basic connection
  3. $conn_id = ftp_connect($ftp_server);
  4.  
  5. // login with username and password
  6. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  7.  
  8. // check connection
  9. if ((!$conn_id) || (!$login_result)) {
  10. echo "FTP connection has failed!";
  11. echo "Attempted to connect to $ftp_server for user $ftp_user_name";
  12. exit;
  13. } else {
  14. echo "Connected to $ftp_server, for user $ftp_user_name";
  15. }
  16.  
  17. // upload the file
  18. $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
  19.  
  20. // check upload status
  21. if (!$upload) {
  22. echo "FTP upload has failed!";
  23. } else {
  24. echo "Uploaded $source_file to $ftp_server as $destination_file";
  25. }
  26.  
  27. // close the FTP stream
  28. ftp_close($conn_id);
  29. ?>
Comments on this Code Snippet
Jun 18th, 2005
0

Re: FTP login - upload

Copied from PHP Manual! Ha Ha.

But Usefull
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005
Jun 28th, 2005
0

Re: FTP login - upload

pretty good
Newbie Poster
forgotteneagle is offline Offline
3 posts
since Jun 2005
Message:
Previous Thread in PHP Forum Timeline: Help with querys please
Next Thread in PHP Forum Timeline: image help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC