使用不同内容类型的curl放置多部分数据

时间:2010-01-22 19:36:19

标签: php xml rest curl http-headers

我想问这个问题,因为php文档没有提到它

如何将xml数据和二进制数据放在一起?

$imagecontent = @file_get_contents($imagelocation);
$xmldata ="<xml></xml>";
$headers = array("MIME-version: 1.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);

我知道如果你将$ data作为数组传递,curl会自动设置为multipart,但是 如何将不同的内容类型与不同的contentvariables相关联?

$xmldata
$imagecontent
Content-Type: application/atom+xml
Content-Type: "jpg"

我有一些使用fputs完成的示例,并且更内联并使用边界。 我不知道你是否也必须用卷曲做这件事,如果是的话怎么做?

有人可以提供一些样本代码吗?

谢谢,理查德

1 个答案:

答案 0 :(得分:0)

我刚刚找到了answer to similar question,它对您有用。

相关问题