Issues

ZF-8890: Undefined index tmp_name when uploading files using Zend_File

Description

There is a bug in the _prepareFiles call in /Zend/File/Transfer/Adapter/Http.php. We are using 1.10. See the error shown below.

Exception 'ErrorException' with message 'Notice: Undefined index:  tmp_name' in [...]/Zend/File/Transfer/Adapter/Abstract.php:1269
Stack trace:
#0 [...]/Zend/File/Transfer/Adapter/Abstract.php(1269): Init->errorToException(Array)
#1 [...]/Zend/File/Transfer/Adapter/Http.php(452): Zend_File_Transfer_Adapter_Abstract->_detectMimeType()
#2 [...]/Zend/File/Transfer/Adapter/Http.php(52): Zend_File_Transfer_Adapter_Http->_prepareFiles()

This occurs because of the order of the $_FILES keys. _prepareFiles() iterates through $_FILES's keys, setting a variable within the iteration which is passed to _detectMimeType(). tmp_name is the second key from $_FILES, but _detectMimeType() uses that index in the first iteration, thus throwing the notice. A *really* dirty fix would be to insert the following on line 441:

$this->_files[$form . '_' . $number . '_']['tmp_name']  = $content['tmp_name'][$number];

Looking at the _prepareFiles() method, it's probably best to rewrite it ;-)

Comments

Fixed with r20496