开发者

Multipart form-data using zend framework

开发者 https://www.devze.com 2023-03-01 04:46 出处:网络
i am trying to use zend framework to post multipart/form-data , to send xml and files $uri = \'http://...\';

i am trying to use zend framework to post multipart/form-data , to send xml and files

$uri = 'http://...';

$update = new Zend_Http_Client();
$update->setUri($uri);
$update->setHeaders('Content-Type: multipart/form-data');

$xml = ' <man>'.
         '<man-id>12</man-id>'开发者_开发技巧.
         '<man-name>Smith</man-name>'.
         '<man-tall>186</man-tall>'.
       '</man>';

$response = $update->encodeFormData('a','file', $xml,'./src/server/TVP.jpg',array("Content-Transfer-Encoding" => "binary"));

How i can exactly use this function ( encodeFormData() ) to do this post ??? or if there any other way that i can use to post ???


To send XML you can use setRawData() like:

$xml = ' <man>'.
         '<man-id>12</man-id>'.
         '<man-name>Smith</man-name>'.
         '<man-tall>186</man-tall>'.
       '</man>';

$update->setRawData($xml);

This is in the Zend Framework Manual about half way down the page under "Sending Raw POST Data"

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消