PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend_Http_Client

Changes to internal uploaded file information storage

In version 1.9 of Zend Framework, there has been a change in the way Zend_Http_Client internally stores information about files to be uploaded, set using the Zend_Http_Client::setFileUpload() method.

This change was introduced in order to allow multiple files to be uploaded with the same form name, as an array of files. More information about this issue can be found in this bug report.

Example 1079. Internal storage of uploaded file information

// Upload two files with the same form element name, as an array
$client = new Zend_Http_Client();
$client->setFileUpload('file1.txt',
                       'userfile[]',
                       'some raw data',
                       'text/plain');
$client->setFileUpload('file2.txt',
                       'userfile[]',
                       'some other data',
                       'application/octet-stream');

// In Zend Framework 1.8 or older, the value of
// the protected member $client->files is:
// $client->files = array(
//     'userfile[]' => array('file2.txt',
                             'application/octet-stream',
                             'some other data')
// );

// In Zend Framework 1.9 or newer, the value of $client->files is:
// $client->files = array(
//     array(
//         'formname' => 'userfile[]',
//         'filename' => 'file1.txt,
//         'ctype'    => 'text/plain',
//         'data'     => 'some raw data'
//     ),
//     array(
//         'formname' => 'userfile[]',
//         'filename' => 'file2.txt',
//         'formname' => 'application/octet-stream',
//         'formname' => 'some other data'
//     )
// );

As you can see, this change permits the usage of the same form element name with more than one file - however, it introduces a subtle backwards-compatibility change and as such should be noted.

Deprecation of Zend_Http_Client::_getParametersRecursive()

Starting from version 1.9, the protected method _getParametersRecursive() is no longer used by Zend_Http_Client and is deprecated. Using it will cause an E_NOTICE message to be emitted by PHP.

If you subclass Zend_Http_Client and call this method, you should look into using the Zend_Http_Client::_flattenParametersArray() static method instead.

Again, since this _getParametersRecursive() is a protected method, this change will only affect users who subclass Zend_Http_Client.

Zend Framework