Issues

ZF-6819: Zend_File_Transfer_Adapter_Http upload failure when using Rename filter

Issue Type: Bug Created: 2009-05-27T02:14:54.000+0000 Last Updated: 2009-06-11T13:06:08.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)

Reporter: Jan Juricek (pog) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer

  • Zend_Filter
  • Zend_Form

Related issues: Attachments:

Description

I wanted to have an upload field, which would not overwrite any existing file (if I uploaded two foobar.jpg files, the second one would fail with an error message).

In order to do that, I had following code in 1.7.*:

    $element->setLabel('Upload a file')
            ->addFilter('Rename',
                        array('overwrite' => false));

Everything worked fine. In 1.8.1, there is a change in Zend_File_Transfer_Adapter_Http at the line 160 and following:

            $filename = $directory . $content['name'];
            $rename   = $this->getFilter('Rename');
            if ($rename !== null) {
                $filename = $rename->getNewName($content['tmp_name']);
                $key      = array_search(get_class($rename), $this->_files[$file]['filters']);
                unset($this->_files[$file]['filters'][$key]);
            }

That leads to Zend_Filter_File_Rename::getNewName(), which returns $content['tmp_name'] with no change. After that, back in Zend_File_Transfer_Adapter_Http, a move_uploaded_file is being called, with the same file name in both attributes, leading to a PHP error and upload failure (uploaded file is not copied to the desired destination)

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Web\Upload\php1C3F.tmp' to 'D:\Web\Upload\php1C3F.tmp' in D:\Web\Lib\Zend\File\Transfer\Adapter\Http.php on line 169

Solution to this issue is either remove the rename filter, or add a "target" parameter - which works, but is not usable for my situation. I don't want to change any name, I just want to ensure that existing file won't be rewrited on the server.

Comments

Posted by Thomas Weidner (thomas) on 2009-06-11T13:06:08.000+0000

Fixed with r16009

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts