I have tried file upload to server using ftp connection in php and it works fine for html file but in case of images, directories are created but no image will be upload in this directories....i have tried following code please help by correcting it
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
ftp_pasv($conn_id, true);
$my_file = "PATH_TO_FILE";
$fp = fopen($my_file, "r");
if (ftp_fput($conn_id, $my_file , $fp , FTP_BINARY)) {
echo "Successfully uploaded
";
} else {
echo "There was a problem while uploading
";
}
fclose($fp);
ftp_close($conn_id);
I have made a silly mistake for image upload i have used ftp_fput instead of ftp_put....using ftp_put it is working fine code for image upload and file upload are given below:
$conn_id = ftp_connect("FTP_SERVER");
$login_result = ftp_login($conn_id, "FTP_USERNAME", "FTP_PASSWORD");
ftp_pasv($conn_id, true);
/*Image Upload*/
if (ftp_put($conn_id, "REMOTE_SERVER_PATH", "LOCAL_SERVER_PATH", FTP_BINARY)) {
echo "Successfully uploaded
";
} else {
echo "ERROR IN FTP UPLOAD";
}
/* HTML UPLOAD */
$fp = fopen("LOCAL_FILE_PATH", "r");
if (ftp_fput($conn_id, "PATH_WHERE_TO_UPLOAD/FILENAME.html" , $fp , FTP_ASCII)) {
echo "Successfully uploaded
";
} else {
echo "There was a problem while uploading
";
}
fclose($fp);
ftp_close($conn_id);
Thanks to all for there help.... :-)