【问题标题】:CakePHP HTTPsocket POST file uploadCakePHP HTTPsocket POST 文件上传
【发布时间】:2012-08-15 01:12:37
【问题描述】:

我有一个 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);
}

【问题讨论】:

    标签: file http cakephp post upload


    【解决方案1】:

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

    http://api.cakephp.org/2.3/class-HttpSocket.html#_put
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-18
      • 2011-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-24
      • 2014-01-26
      相关资源
      最近更新 更多