ssl - Require explicit FTP over TLS with PHP -


i'm trying upload file ftp php. requirement server's admin encryption should require explicit ftp on tls. , that's i'm getting error warning: ftp_fput() [function.ftp-fput]: can't open data connection.. manage connect(in passive mode), fails upload function(ftp_put, ftp_nb_put, ftp_fput). error same times. i'm trying following code:

$host = 'ftps.someserver.net'; $user = '****'; $pass = '****'; $filename = "somefile.txt"   $dest_file = $filename; $source_file = dirname(__file__) . '/' . $filename;  $fp = fopen($source_file, 'r');  $ftp = ftp_ssl_connect($host, 21, 180);   if (ftp_login($ftp,$user,$pass)) {      var_dump(ftp_pasv($ftp, true)); // gives me true     // # first way     // ftp_put($ftp, $dest_file, $source_file, ftp_binary);      // # second     // $ret = ftp_nb_put($ftp, $dest_file, $source_file, ftp_binary, ftp_autoresume);      // while (ftp_moredata == $ret)     // {     //   $ret = ftp_nb_continue($ftp);     // }      // # third     if (ftp_fput($ftp, $dest_file, $fp, ftp_ascii)) { // trying ftp_binary , ftp_ascii.         echo "successfully uploaded\n";     } else {         echo "there problem while uploading\n";     }        } ftp_close($ftp); fclose($fp); 

it works fine own ftp, not asks explicit tls. ideas appreciated.

try using ftp_pasv($ftp, true);. found in five year old comment on php.net, , worked me.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -