Index: Zend/Http/Client.php =================================================================== --- Zend/Http/Client.php (revision 11188) +++ Zend/Http/Client.php (working copy) @@ -666,6 +666,9 @@ $this->setEncType(self::ENC_FORMDATA); $this->files[$formname] = array(basename($filename), $ctype, $data); + // Create placeholder in $this->paramsPost in order to preserve the + // position of this file relative to other parameters + $this->paramsPost[$formname] = null; return $this; } @@ -1001,18 +1004,19 @@ $boundary = '---ZENDHTTPCLIENT-' . md5(microtime()); $this->setHeaders('Content-type', self::ENC_FORMDATA . "; boundary={$boundary}"); - // Get POST parameters and encode them + // Get POST parameters/files and encode them $params = $this->_getParametersRecursive($this->paramsPost); foreach ($params as $pp) { - $body .= self::encodeFormData($boundary, $pp[0], $pp[1]); + if ($pp[1] === null && isset($this->files[$pp[0]])) { + // Encode file + $file = $this->files[$pp[0]]; + $fhead = array('Content-type' => $file[1]); + $body .= self::encodeFormData($boundary, $pp[0], $file[2], $file[0], $fhead); + } else { + $body .= self::encodeFormData($boundary, $pp[0], $pp[1]); + } } - // Encode files - foreach ($this->files as $name => $file) { - $fhead = array('Content-type' => $file[1]); - $body .= self::encodeFormData($boundary, $name, $file[2], $file[0], $fhead); - } - $body .= "--{$boundary}--\r\n"; break;