I use Zend Form and upload the file. I need to rename and add addFilter. But if I try to get the file extension, as in the code, I get the error message "Too many files, maximum" 1 "are allowed, but" 2 "are given." If I try to get the extension using $ _FILES, it looks like it might work, but it seems ugly. Could you tell me how to rename a file while preserving its extension?
$form = new Form_ImportSubscribers();
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$extension = pathinfo($form->file->getFileName(), PATHINFO_EXTENSION);
$form->file->addFilter('Rename', $accountId . '_' . time() . '.' . $extension);
if (!$form->file->receive()) {
$this->view->form = $form;
$this->view->listName = $list->list_name;
return;
}
source
share