我试图通过隐式FTPS使用PHP cURL上传一个txt文件(大小为2KB)到Sharefile,但我收到:
连接在30000毫秒后超时
正在关闭连接0
我的代码如下,任何建议是赞赏:
$fp = fopen($local_file, 'rw+');
$ftp_url = 'ftps://subdomain.sharefileftp.com/'.$ftp_path;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ftp_url);
curl_setopt($ch, CURLOPT_PORT, 990);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
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);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
curl_close($ch);
curl_getinfo
的输出数组大部分是设置了url的空值。curl_setopt($ch, CURLOPT_STDERR, fopen('curl.txt', 'w+'));
输出以下内容(本帖简称):
* Expire in 0 ms for 1 (transfer 0x56523a8e1070)
* Expire in 1 ms for 1 (transfer 0x56523a8e1070)
* TCP_NODELAY set
* Trying X.X.X.X...
* Expire in 200 ms for 4 (transfer 0x56523a8e1070)
* Connection timed out after 30002 milliseconds
* Closing connection 0
1条答案
按热度按时间aelbi1ox1#
您可能需要尝试添加
CURLOPT_TRANSFERTEXT,true
我会尝试这样的方式:
当我遇到麻烦时,我会添加以下选项
通常您的请求标题会给予您一些线索。