Monday, 15 February 2010

php - Images are not storing in FTP -



php - Images are not storing in FTP -

i have tried files upload server using ftp connection in php , not working, connecting getting error "connected xxxxxxxxxxx, user xxxxxxxxxxxxx ftp upload has failed!" have tried next code please help correcting it,..

<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>welcome</title> </head> <body> <form action="upload.php" enctype="multipart/form-data" method="post"> <input name="file" type="file" /> <input name="submit" type="submit" value="upload file" /> </form> </body> </html>

upload.php

<?php $ftp_server = "xxxx"; $ftp_user_name = "xxxxx"; $ftp_user_pass = "xxxxxxxxxx"; $destination_file = "./imagetest/123/"; $source_file = $_files['file']['tmp_name']; // set basic connection $conn_id = ftp_connect($ftp_server); ftp_pasv($conn_id, true); // login username , 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 connect $ftp_server user $ftp_user_name"; exit; } else { echo "connected $ftp_server, user $ftp_user_name"; } // upload file $upload = ftp_put($conn_id, $destination_file, $source_file, ftp_binary); // check upload status if (!$upload) { echo "ftp upload has failed!"; } else { echo "uploaded $source_file $ftp_server $destination_file"; } // close ftp stream ftp_close($conn_id); ?>

you have add together filename after path.

replace below code , try,

$destination_file = "./imagetest/123/".$_files['file']['name'];

php mysql database forms ftp

No comments:

Post a Comment