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

Issue Type: Bug Created: 2010-01-21T07:44:23.000+0000 Last Updated: 2010-01-21T12:07:20.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: D. ter Horst (daanzzzzz) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer

Related issues: Attachments:


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.

<pre class="literal">
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:

<pre class="literal">
$this->_files[$form . '_' . $number . '_']['tmp_name']  = $content['tmp_name'][$number];

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


Posted by Thomas Weidner (thomas) on 2010-01-21T12:07:20.000+0000

Fixed with r20496

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.