我尝试使用隐含的ssl在ftp空间上传文件。
我连接它以上传提示PROT P的文件。
我环顾四周,但我找不到任何关于如何激活它的内容。 你知道帮帮我吗?
我留下了我的代码和详细的
$file = "prova_4u.csv";
$ftp_server="mio ftps";
$ftp_user_name="mio user";
$ftp_user_pass="mia pass";
$path="/";
//$file =dirname(__FILE__)."/../application/archivosastras/".$localfile.".csv";
$remote_file = $path.$file;
$ch = curl_init();
$fp = fopen($file,'r');
curl_setopt($ch, CURLOPT_URL, $ftp_server.$remote_file);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_PORT, 990);
//SSL stuff curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_USE_SSL, TRUE);
curl_setopt($ch, CURLOPT_FTP_SSL, CURLOPT_FTPSSLAUTH);
curl_setopt($ch, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS);
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FTPS);
curl_setopt($ch, CURLOPT_USERPWD,"$ftp_user_name:$ftp_user_pass");
//curl_setopt($ch,CURLOPT_SSLVERSION, 3);
//end SSL curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
$exec = curl_exec ($ch);
echo "\n\r".$exec."\n\r";
$error_no = curl_errno($ch); $error_msg = curl_error($ch);
echo "no - ".$error_no." - ".$error_msg."\n\r\n\r";
curl_close ($ch);
if ($error_no == 0) { $error = 'File uploaded succesfully.'; } else {
$error = 'File upload error.'; }
echo "\n\r".$error."\n\r";
fclose($fp);
详细输出
About to connect() to *********** port 990
* Trying * * * * * * * *... * connected
* Connected to * * * * * * (* * * * * * * *) port 990
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
* subject: /CN=*****/C=IT/ST=Italy/L=Milan/O=***/OU=ICT/emailAddress=*****
* start date: 2015-09-04 15:42:55 GMT
* expire date: 2016-09-03 15:42:55 GMT
* issuer: /CN=*****/C=IT/ST=Italy/L=Milan/O=****/OU=ICT/emailAddress=info@assistenzacasa.com
* SSL certificate verify result: self signed certificate (18), continuing anyway. < 220-Welcom to "******" FTP over TLS
service. < 220 Access by unauthorized users is prohibited and may be
prosecuted.
> USER **** < 331 Password required for ***
> PASS ****** < 230 Logged on
> PBSZ 0 < 200 PBSZ=0
> PWD < 257 "/" is current directory.
* Entry path is '/'
> EPSV
* Connect data stream passively < 229 Entering Extended Passive Mode (|||50000|)
* Trying *****... * connected
* Connecting to ****** (******) port 50000
> TYPE I < 200 Type set to I
> STOR prova_4u.csv < 521 PROT P required
* Failed FTP upload: 521
* Uploaded unaligned file size (0 out of 21 bytes)
* Connection #0 to host **** left intact
no - 25 - Failed FTP upload: 521
* Closing connection #0
File upload error.
由于