//excerpt
$file = new Zend_Form_Element_File(\'file\');
$file->setLabel(\'File to upload:\')
->setRequired(true)
->addValidator(\'NotEmp
Folks, here's a simple example of a form that uses the rename filter on a file after it's been uploaded. There are many more options and yes, you'd need to take in to consideration existing files, but to get you started, here you go.
When the file's uploaded through the form below, it will be renamed to 'config.ini'.
$form = new Zend_Form;
$form->setAction('/default/index/file-upload')
->setMethod('post');
$uploadFile = new Zend_Form_Element_File('uploadfile');
$uploadFile->addFilter(new Zend_Filter_File_Rename(
array('target' => 'config.ini'))
)
->setRequired(true)
->setLabel('Upload file:');
$form->addElement($uploadFile);
$form->addElement(new Zend_Form_Element_Submit('submit'));
if ($form->isValid($_POST)) {
$values = $form->getValues();
}