- print doesn't like commas
[m6w6/ext-http] / docs / examples / Multipart_Posts.php
1 <?php
2 $r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_POST);
3
4 // if redirects is set to true, a single redirect is allowed;
5 // one can set any reasonable count of allowed redirects
6 $r->setOptions(
7 array( 'cookies' => array('MyCookie' => 'has a value'),
8 'redirect' => true,
9 )
10 );
11
12 // common form data
13 $r->setPostFields(
14 array( 'name' => 'Mike',
15 'mail' => 'mike@php.net',
16 )
17 );
18 // add the file to post (form name, file name, file type)
19 $r->addPostFile('image', 'profile.jpg', 'image/jpeg');
20
21 try {
22 print $r->send()->getBody();
23 } catch (HttpException $e) {
24 print $e;
25 }
26 ?>