943,568 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 372
  • PHP RSS
Nov 21st, 2008
0

can someon explain it to me please

Expand Post »
In the follwing code i want want to know how i can put my information in the
file
filename
distinamtion_file


i want to use this code to upload a file from my computer to ftp server
file that i want to upload is in my 'C/SITE/file.txt@ folder
and i want to uplload it to
/WEEBROOT/WILBLOURN/FTPTEST
can some wriye to me the syntax for this.
code is belove



PHP Syntax (Toggle Plain Text)
  1. <?
  2. $name = "FILE NAME";
  3. $filename = "FILE NAME WITH FULL PATH";
  4.  
  5. //-- Code to Transfer File on Server Dt: 06-03-2008 by Aditya Bhatt --//
  6. //-- Connection Settings
  7. $ftp_server = "IP ADDRESS"; // Address of FTP server.
  8. $ftp_user_name = " SERVER USERNAME"; // Username
  9. $ftp_user_pass = " SERVER PASSWORD"; // Password
  10. $destination_file = " SERVER FILE PATH TO UPLOAD VIA FTP_PUT"; //where you want to throw the file on the webserver (relative to your login dir)
  11.  
  12. $conn_id = ftp_connect($ftp_server) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>"); // set up basic connection
  13.  
  14. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<span style='color:#FF0000'><h2>You do not have access to this ftp server!</h2></span>"); // login with username and password, or give invalid user message
  15.  
  16. if ((!$conn_id) || (!$login_result)) { // check connection
  17. // wont ever hit this, b/c of the die call on ftp_login
  18. echo "<span style='color:#FF0000'><h2>FTP connection has failed! <br />";
  19. echo "Attempted to connect to $ftp_server for user $ftp_user_name</h2></span>";
  20. exit;
  21. } else {
  22. //echo "Connected to $ftp_server, for user $ftp_user_name <br />";
  23. }
  24.  
  25. $upload = ftp_put($conn_id, $destination_file.$name, $filename, FTP_BINARY); // upload the file
  26. if (!$upload) { // check upload status
  27. echo "<span style='color:#FF0000'><h2>FTP upload of $filename has failed!</h2></span> <br />";
  28. } else {
  29. echo "<span style='color:#339900'><h2>Uploading $name Completed Successfully!</h2></span><br /><br />";
  30. }
  31. ftp_close($conn_id); // close the FTP stream
  32. ?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
asifkamalzahid is offline Offline
17 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: uploading to ftp server my directory hae some problom
Next Thread in PHP Forum Timeline: fwrite not working with ob_start, Any ideas?





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


Follow us on Twitter


© 2011 DaniWeb® LLC