|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP & FTP? Any experts to help a beginner
Need help on getting started with FTP functions of PHP but seem stuck at very first obstacle - can anybody assist? I can connect to ftp server and do all sorts of directory based things such as creating and changing but cannot successfully upload a file from my PC - so very basic flaw in FTP useage.
<?php $ftp_server="www.mysite.uk"; $ftp_user_name="myname"; $ftp_user_pass="mypass"; $destination_file="test.txt"; $source_file="c:\dja\test.txt"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name<p>"; //stuff inserted to test connection - all works ok ftp_chdir($conn_id, "/djapix/"); echo ftp_pwd($conn_id); echo"<p>"; ftp_mkdir($conn_id, "testdir"); //just testing! } // upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII,0); // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } // close the FTP stream ftp_close($conn_id); ?> |
|
#2
|
||||
|
||||
|
This thread has been moved from the .NET forum, to the appropriate forum.
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > PHP & FTP? Any experts to help a beginner |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|