FTP login - upload

Scribbller Scribbller is offline Offline Mar 25th, 2005, 12:27 pm |
0
Allows a user to login to an ftp and upload files.
Quick reply to this message  
PHP Syntax
  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. ?>
0
thandermax thandermax is offline Offline | Jun 18th, 2005
Copied from PHP Manual! Ha Ha.

But Usefull
 
0
forgotteneagle forgotteneagle is offline Offline | Jun 28th, 2005
pretty good
 
 

Message:


Similar Threads
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC