Php Ftp Code


I am trying to built a code for FTP in yii. Every thing is working fine but problem occures when i am trying to FTPES (secure server).

I can establish connect, create and delete folder but when i am trying to move file it transfers 0byte file. My code is given below that is in core php





 echo $conn_id = ftp_ssl_connect("") or die("Could not connect");       

 //echo $conn_id = ftp_ssl_connect($ftp_server);



// login with username and password

echo $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

//echo ftp_pwd($conn_id); // /

//echo ftp_mkdir($conn_id,"images/testdir");


echo ftp_pasv($conn_id,true);

$source = fopen("youtube.php","r");

// Print a directory listing

//print_r(ftp_nlist($conn_id, "/images"));

 //print_r( $source );

 //echo ftp_fput($conn_id,"images/a.php",$source,FTP_ASCII);


$transfer_result = ftp_put( $conn_id, "images/a.php", 'youtube.php', FTP_ASCII );

 if( $transfer_result)


        echo "Success";




        echo "An error occured";



// close the ssl connection



anyone please rectify by issue .


Is your "images" folder writable?

Why do you call “fopen(‘youtube.php’)” before make ftp_put ?

yes my image folder is writable.