lilwing Posted August 20, 2007 Share Posted August 20, 2007 i am trying to make an ftp upload page for a website i keep getting 'ftp upload failed'. not sure what the problem is. here is the form. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Untitled Document</title> </head> <body> <form enctype="multipart/form-data" action="putimage.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> File: <input name="userfile" type="file"> <input type="submit" value="Upload"> </form> </body> </html> and here is the php handler for it. <?php $ftp_server = "*******"; $ftp_user_name = "********"; $ftp_user_pass = "********"; // 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"; } // upload the file $upload = ftp_put($conn_id, $file, $file, FTP_BINARY); // 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/65853-help-ftp-with-php/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.