I'm trying to connect to a remote ftp server using cURL and ftps in PHP. The following is my code:
curl_setopt($ch, CURLOPT_URL, 'ftp://$server/'.$localfile); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); //SSL stuff curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_TRY); curl_setopt($ch, CURLOPT_FTPSSLAUTH, 1); curl_setopt($ch, CURLOPT_PORT, $port); curl_setopt($ch, CURLOPT_USERPWD, $user:$pass); //curl_setopt($ch, CURL_SSLVERSION, 3); //end curl_setopt($ch, CURLOPT_INFILESIZE, filesize($path . $localfile)); curl_exec ($ch);
It may well be that some of those options cancel each other out, or aren't compatible, but i've been trying combinations of that for a while and none of them work.
If i use 'ftp://' for the CURLOPT_URL param then i get 'Access denied: 501'. Which labels itself curl error 67.
If i use 'ftps://' for the CURLOPT_URL param then i get 'error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol'. Which labels itself curl error 35.
I've not got direct access to the remote server, but i've been told that the logs show no attempt to connect whenever i have run this script.
The connection is required on port 61000, not a standard ftp(s) port.
Any guidance that anyone can offer would be greatly appreciated.
Some other information that may be of use:
My cURL version is
libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
PHP was compiled with '--with-openssl'
And PHP logs show the following messages:
PHP Notice: Use of undefined constant CURLOPT_FTP_SSL - assumed 'CURLOPT_FTP_SSL' in ... PHP Notice: Use of undefined constant CURLFTPSSL_TRY - assumed 'CURLFTPSSL_TRY' in ... PHP Notice: Use of undefined constant CURLOPT_FTPSSLAUTH - assumed 'CURLOPT_FTPSSLAUTH' in ...
This post has been edited by MBraybrook: 22 April 2009 - 03:34 AM