HttpRequest An multipart POST request : HttpRequest : Development PHP Source Code

PHP Source Code » Development » HttpRequest »


HttpRequest An multipart POST request

The following example shows an multipart POST request, with two form fields and an image that's supposed to be uploaded to the server. It's a bad habit as well as common practice to issue a redirect after an received POST request, so we'll allow a redirect by enabling the redirect option.
= new HttpRequest(''HTTP_METH_POST);    
// if redirects is set to true, a single redirect is allowed;    
// one can set any reasonable count of allowed redirects    
'cookies' => array('MyCookie' => 'has a value'),    
'redirect' => true,    
// common form data    
'name' => 'Mike',    
'mail' => '',    
// add the file to post (form name, file name, file type)    
try {    
} catch (
HttpException $e) {    

HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Development
» HttpRequest