How to send a file using secure FTP protocol SSL

I appreciate any help that can be offered on this. At the end of the online application, I take client data (several fields), put them in a CSV file and try to send it to another client using SSL, but I have no idea how to do this. I also store information about the local database and I hope that the process is somewhat similar.

I have already sent links to view SSH2 instructions from php.net SSN2

but honestly, this is like reading Chinese for me. I do not understand the instructions and do not want to install any extensions, modify the PHP.ini file or something like that (especially since we do not own the server through which the information is sent).

Is there an easy and safe way to transfer this file to the SSL protocol provided to us?

Thank!

+3
source share
2 answers

The only way I managed to execute ftp over SSL using php was to use the php function exec () to execute curl . The PHP curl library did not work, because at that time the skip-pasv-ip option did not exist, and this was absolutely necessary. Sort of:

curl --user <username:password> --disable-epsv --ftp-pasv --ftp-skip-pasv-ip --ftp-ssl --sslv2  --cert <path/to/certificate> -T <path/to/uploadfile> <hostname>

You may need to change the curl settings to suit your needs.

+2
source

, ftp_ssl_connect, SSL-FTP-, - , , . :

//Create your connection
$ftp_conn = ftp_ssl_connect( $host, $you_can_provide_a_port );

//Login
$login_result = ftp_login($ftp_conn, $user, $pass);

if( $login_result )
{
    //Set passive mode
    ftp_pasv( $ftp_conn, true );
    // Transfer file
    $transfer_result = ftp_put( $ftp_conn, $dest_file_path, $source_file_path, FTP_BINARY );

    //Verify if transfer was successfully made
    if( $transfer_result)
    {
        echo "Success";
    }
    else
    {
        echo "An error occured";
    }
}

http://www.php.net/manual/en/function.ftp-ssl-connect.php

+6

Source: https://habr.com/ru/post/1745847/


All Articles