Esempio n. 1
0
 /**
  * @ignore
  */
 public static function build_http_query_multi($params)
 {
     if (!$params) {
         return '';
     }
     uksort($params, 'strcmp');
     $pairs = array();
     self::$boundary = $boundary = uniqid('------------------');
     $MPboundary = '--' . $boundary;
     $endMPboundary = $MPboundary . '--';
     $multipartbody = '';
     foreach ($params as $parameter => $value) {
         if ($value[0] == '@') {
             $url = ltrim($value, '@');
             $content = file_get_contents($url);
             //$array = explode( '?', basename( $url ) );
             $filename = uniqid() . '.jpg';
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
             $multipartbody .= "Content-Type: image/jpeg\r\n\r\n";
             $multipartbody .= $content . "\r\n";
         } else {
             $multipartbody .= $MPboundary . "\r\n";
             $multipartbody .= 'content-Disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
             $multipartbody .= $value . "\r\n";
         }
     }
     $multipartbody .= $endMPboundary;
     return $multipartbody;
 }