PHP Classes
elePHPant
Icontem

File: multipart_post_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of GuinuX  >  Advanced HTTP Client  >  multipart_post_test.php  >  Download  
File: multipart_post_test.php
Role: Example script
Content type: text/plain
Description: Multipart post example script
Class: Advanced HTTP Client
GET, HEAD, POST methods with a lot of features
Author: By
Last change: Applied change for release 1.1 of the class
Date: 12 years ago
Size: 842 bytes
 

Contents

Class file image Download
<?php
   
require_once( 'http.inc' );
   
   
$fields = array( 'user' => 'GuinuX',
                       
'password' => 'mypass',
                       
'lang' => 'US'
               
);
   
   
$files = array();
   
$files[] = array( 'name' => 'myfile1',
                   
'content-type' => 'text/plain',
                   
'filename' => 'test1.txt',
                   
'data' => 'Hello from File 1 !!!'
       
);
   
   
$files[] = array( 'name' => 'myfile2',
                       
'content-type' => 'text/plain',
                       
'filename' => 'test2.txt',
                       
'data' => "bla bla bla\nbla bla"
       
);
   
       
   
$http_client = new http( HTTP_V11, false );
   
$http_client->host = 'www.myhost.com';
    if (
$http_client->multipart_post( '/upload.pl', $fields, $files ) == HTTP_STATUS_OK )
             print(
$http_client->get_response_body());
        else
           print(
'Server returned status code : ' . $http_client->status);
    unset(
$http_client );
?>