title: Zend Framework: image upload
body: <p>I want to upload an image with Zend Framework version 1.9.6. The uploading itself works fine, but I want a couple of other things as well ... and I'm completely stuck.</p>
  
  <ul>
  <li>Error messages for failing to upload an image won't show up.</li>
  <li>If a user doesn't enter all the required fields but has uploaded an image then I want to display the uploaded image in my form. Either as an image or as a link to the image. Just some form of feedback to the user.</li>
  <li>I want to use Zend_ Validate_ File_ IsImage. But it doesn't seem to do anything.</li>
  <li>And lastly; is there some automatic renaming functionality?</li>
  </ul>
  
  <p>All ideas and suggestions are very welcome. I've been struggling for two days now.</p>
  
  <p>These are simplified code snippets:</p>
  
  <p><strong>myform.ini</strong></p>
  
  <pre><code>method = "post"
  
  elements.title.type = "text"
  elements.title.options.label = "Title"
  elements.title.options.attribs.size = 40
  elements.title.options.required = true
  
  elements.image.type = "file"
  elements.image.options.label = "Image"
  elements.image.options.validators.isimage.validator = "IsImage"
  
  elements.submit.type = "submit"
  elements.submit.options.label = "Save"
  </code></pre>
  
  <p><strong>TestController</strong></p>
  
  <pre><code>&lt;?php
  class Admin_TestController extends Zend_Controller_Action
  {
    public function testAction ()
    {
      $config = new Zend_Config_Ini(MY_SECRET_PATH . 'myform.ini');
      $f = new Zend_Form($config);
  
      if ($this-&gt;_request-&gt;isPost())
      {
        $data = $this-&gt;_request-&gt;getPost();
  
        $imageElement = $f-&gt;getElement('image');
        $imageElement-&gt;receive();
  
        //$imageElement-&gt;getValue();
  
        if ($f-&gt;isValid($data))
        {
          //save data
          $this-&gt;_redirect('/admin');
        }
  
        else
        {
          $f-&gt;populate($data);
        }
      }
  
      $this-&gt;view-&gt;form = $f;
    }
  }
  ?&gt;
  </code></pre>
  
  <p>My view just echo's the 'form' variable.</p>