я адаптирую этот пример моих собственных форм: http://framework.zend.com/manual/2.1/en/modules/zend.form.file-upload.htmlПочему плагины ZF2 PRG возвращаются [fileUploadFileErrorFileNotFound] => Файл не найден?
Когда я добавить свой файл с помощью Choose File
кнопку на моей форме, а затем отправить форму, я получаю это:
Array
(
[fileUploadFileErrorFileNotFound] => File was not found
)
и переменное содержание которого распечатывается выше, это (после подачи формы):
$fileErrors = $form->get('character-ref')->getMessages();
В чем проблема? На данный момент я понятия не имею. Я посмотрел на фильтр RenameUpload
и несколько сайтов, но в данный момент у вас нет подсказки.
Мой код в соответствующих случаях:
class CommissionInputFilter implements InputFilterAwareInterface
{
function getInputFilter()
{
$inputFilter = new InputFilter();
//this is the filter that is supposed to make
//PRG Plugin file upload possible
$renameFilter = new RenameUpload(array(
'target' => "./data/uploads/",
'randomize' => true
));
// File Input - I am not sure if this is the way to do it
//some examples do not use FileInput
$fileInput = new FileInput('character-ref');
$fileInput->setRequired(false);
$fileInput->getFilterChain()->attach($renameFilter);
$inputFilter->add($fileInput);
return $inputFilter;
}
}
//code inside controller
public function addAction()
{
$form = new CommissionForm();
$tempFile = null;
$prg = $this->fileprg($form);
if ($prg instanceof \Zend\Http\PhpEnvironment\Response) {
return $prg;
} elseif (is_array($prg)) {
//**************************************************
//this line below is where I set my input filter for the form
//the filter that contains PRG Rename pluging supposedly
//One interesting note is if I *Remove* the line below
//then the PRG Plugin keeps the file name as it is supposed to
//**************************************************
$form->setInputFilter((new CommissionInputFilter())->getInputFilter());
if ($form->isValid()) {
$output = new CommissionOutput();
$commission = $output->getCommission($form->getData());
$id = $this->repository->saveCommission($commission);
$view = new ViewModel();
$view->setTemplate('commission/commission/thank_you');
$view->setVariables($prg);
return $view;
} else {
//********************************************************
//My Properly-filled out form ends up here with file errors
//********************************************************
$fileErrors = $form->get('character-ref')->getMessages();
if (empty($fileErrors)) {
$tempFile = $form->get('character-ref')->getValue();
}
}
}
return array(
'form' => $form,
'characterRefFile' => $tempFile
);
}