CakePHP HTTPsocket POST文件上传

时间:2012-08-19 08:31:26

标签: file http cakephp post upload

我有一个CakePHP函数,它授权一个HTTP套接字,然后使用该套接字从远程服务器上传文件。对于该服务器上的某些文件,一切正常,但其中一些文件没有完全传输。

我已经看过Wireshark上发生了什么(虽然我理解的很少)并且看起来我的服务器正在发送SSL警报21,我相信这意味着它无法解密所接收的数据。然后它开始向远程服务器发送被忽略的重置请求。

当我通过浏览器执行此操作时,文件下载正常。我现在完全陷入困境,还有什么可以看的吗?

public function connect() {
  $httpSocket = new HttpSocket();
  $zipFile = fopen(TMP . 'cif_schedule.gz', 'w');

  $postData = array('j_username' => 'my_username', 'j_password' => 'my_password');
  $authResponse = $httpSocket->post('https://login_url', $postData, array('redirect' => true));

  $httpSocket->setContentResource($zipFile);
  $fileResponse = $httpSocket->get('file_url', array(), array('redirect' => true));

  fclose($zipFile);
}

1 个答案:

答案 0 :(得分:0)

我认为您应该使用PUT,因为Post仅用于传递数据。 PUT用于文件目的。

http://api.cakephp.org/2.3/class-HttpSocket.html#_put
相关问题