- add missing support for raw post data (HttpRequest)
[m6w6/ext-http] / docs / examples / Multipart_Posts.php
diff --git a/docs/examples/Multipart_Posts.php b/docs/examples/Multipart_Posts.php
new file mode 100644 (file)
index 0000000..eb9b171
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+$r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_POST);
+
+// if redirects is set to true, a single redirect is allowed;
+// one can set any reasonable count of allowed redirects
+$r->setOptions(
+       array(  'cookies'       => array('MyCookie' => 'has a value'),
+                       'redirect'      => true,
+       )
+);
+
+// common form data
+$r->setPostFields(
+       array(  'name'  => 'Mike',
+                       'mail'  => 'mike@php.net',
+       )
+);
+// add the file to post (form name, file name, file type)
+$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
+
+try {
+       print $r->send()->getBody();
+} catch (HttpException $e) {
+       print $e;
+}
+?>