Conexion FTP con PHP
February 1st, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | < ? function ftpConnection($filename, $source_file,$destination_file) { // set up basic connection $conn_id = ftp_connect ( FTP_SERVER ); $destination_file .= $filename; // login with username and password $login_result = ftp_login ( $conn_id, FTP_USER,FTP_PASS ); // check connection if ((! $conn_id) || (! $login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to " . FTP_SERVER . "for user " .FTP_USER; exit (); } else { echo "Connected to " . FTP_SERVER . " for user " . FTP_USER; } // upload the file $upload = ftp_put ( $conn_id, $destination_file, $source_file.$filename, FTP_BINARY ); // check upload status if (! $upload) { echo "FTP upload has failed!"; } else { echo "Uploaded as $destination_file"; } // close the FTP stream ftp_close ( $conn_id ); } ?> |