Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
- * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- namespace Application\Controller;
- use Zend\Mvc\Controller\AbstractActionController;
- use Application\Form\UploadForm;
- class FileController extends AbstractActionController {
- public function indexAction() {
- $form = new UploadForm('upload-form');
- $tempFile = null;
- $prg = $this->fileprg($form);
- if ($prg instanceof \Zend\Http\PhpEnvironment\Response) {
- return $prg; // Return PRG redirect response
- } elseif (is_array($prg)) {
- if ($form->isValid()) {
- $data = $form->getData();
- // Form is valid, save the form!
- return $this->redirect()->toRoute('upload-form/success');
- } else {
- // Form not valid, but file uploads might be valid...
- // Get the temporary file information to show the user in the view
- $fileErrors = $form->get('image-file')->getMessages();
- if (empty($fileErrors)) {
- $tempFile = $form->get('image-file')->getValue();
- }
- }
- }
- return array(
- 'form' => $form,
- 'tempFile' => $tempFile,
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement