Search code examples
phpftpsslftps

ftp_ssl_connect with implicit ftp over tls


Can ftp_ssl_connect handle Implicit FTP over TLS? By default it uses explicit.

I'm trying to upload to a server that accepts only Implicit ftp over tls on port 990; has anybody run into this as of yet? How did you fix it?


Solution

  • ftp_ssl_connect is only explicit

    if you need implicit, use curl

    $fp = fopen($path, 'r');
    $ftp_server = 'ftps://'.$server.'/'.$filename; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $ftp_server);
    curl_setopt($ch, CURLOPT_USERPWD,$user.':'.$pass);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);
    curl_setopt($ch, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS);
    curl_setopt($ch, CURLOPT_UPLOAD, 1);
    curl_setopt($ch, CURLOPT_INFILE, $fp);
    
    $output = curl_exec($ch);
    $error_no = curl_errno($ch);
    //var_dump(curl_error($ch));
    curl_close($ch);