views:

337

answers:

1

The code says Zend_Form_element_File::setDestination() is depricated and to use the rename filter. However the rename filter is currently codes such that when path is set, only temporary name is given. Original filename is lost.

<?php
$file = new Zend_Form_Element_File();
$file->setDestination('/var/www/project/public');
?>

vs

<?php
$file = new Zend_Form_Element_File();
$file->addFilter('Rename', array('target' => '/var/www/project/public'));
?>

Any solution to upload files so that it preserves original filename structure but checks for existing file and appends _1.ext or _2.ext?

A: 

After submitting the form you can inspect the $_FILES['file_element']['name'] check for existing files and then set the rename filter on your form element before calling the $form->getValues()/isValid() or $form->file_element->receive().

Goran Jurić