views:

308

answers:

2

I appreciate any help that can be offered on the subject. At the end of an online enrollment, I am taking customer data (several fields), putting them in a CSV file and trying to submit to another client over SSL protocol but have no idea how this is done. I am also storing the information on a local database and am hoping the process is somewhat similar.

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

but to be honest this is like reading Chinese to me. I do not understand the instructions and am not looking to install any extensions, modify the PHP.ini file or anything of the sort (especially since we do not own the server the information is being sent through).

Is there a simple, secure way of transmitting this file to the SSL protocol provided to us?

Thanks!

+1  A: 

Perhaps you could use *ftp_ssl_connect* for that matter, which is used to open a secure SSL-FTP connection, and to upload a file is just a straight forward process, just create the connection to the server, and put the file up there. A basic example could be:

//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";
    }
}

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

falomir
@falomir - thank you for the advice. I will give it a shot and let you know the results!
JM4
@falomir - this did not work as needed. I am given the client $host as IP address and it simply times out after 60 seconds. I know the FTPS works because I am able to connect with local FTP client
JM4
+1  A: 

The only way I've managed to do ftp over SSL using php was to use php's exec() function to execute a curl command. PHP's curl library would not work because at the time, the skip-pasv-ip option did not exist and it was something that was absolutely required. Something like:

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 modify the curl options to suit your needs.

Rob Apodaca
@rob - Thanks for the advice. I am not familiar with Curl but i will give this a shot and let you know how it turns out!
JM4
@JM4 - Also wanted to point out that you might be able to use PHP's curl library. I wasn't able to use it because I could not set the ftp-skip-pasv-ip option - it wasn't available for the version of PHP I was using. If you don't need that option and have curl support available to you, give that a go first.
Rob Apodaca
@Rob Apodaca - I am not sure how to use curl inline as you have denoted above. I also referenced (http://curl.haxx.se/docs/manual.html) and they list inline just like you did. All of the CURL instructions I have seen are multiple lines with very specific options. I am trying to connect to a host IP, with given username and password, then dump a file in a specific directory. Any ideas?
JM4