Ich habe dieses Beispiel meine eigenen Formen anzupassen: http://framework.zend.com/manual/2.1/en/modules/zend.form.file-upload.htmlWarum gibt ZF2 PRG-Plugins zurück [fileUploadFileErrorFileNotFound] => Datei wurde nicht gefunden?
Wenn ich meine Datei mit Choose File
Taste auf meiner Form hinzufügen und dann das Formular abzuschicken, erhalte ich dieses:
Array
(
[fileUploadFileErrorFileNotFound] => File was not found
)
und die Variable Inhalt davon ist das oben ausgedruckt ist dies (nach dem Formular einreichen):
$fileErrors = $form->get('character-ref')->getMessages();
Was kann das Problem sein? Ich habe zur Zeit keine Ahnung. Ich schaute auf RenameUpload
Filter und ein paar Seiten, aber fehlt der Hinweis an dieser Stelle.
My-Code, wo relevant:
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
);
}