title: cakephp 2.1 how to upload an image in a simple form and viewing it
body: <p>Its so crazy how something so simple can be so difficult.</p>
  
  <p>Please calling all cakephp 2.1 gurus. I have a form, it has a name and text image (var) field.</p>
  
  <p>I would like to simply post an image, no resizing, no thumbnail, not anything special, just a simple mvc example of posting up an image and viewing it in the view.ctp.</p>
  
  <p>Thats it. I have gone through the /en/2.1 book and api on cakephp.org but I just can't seem to get the mvc working as far as seeing it upload into a folder and viewing it in ctp.</p>
  
  <p>My controller</p>
  
  <pre><code>public function add() {
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;ListShExPainImage-&gt;create();
          if ($this-&gt;ListShExPainImage-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;Session-&gt;setFlash(__('The list sh ex pain image has been saved'));
              $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash(__('The list sh ex pain image could not be saved. Please, try again.'));
          }
      }
  }
  
  public function view($id = null) {
      $this-&gt;ListShExPainImage-&gt;id = $id;
      if (!$this-&gt;ListShExPainImage-&gt;exists()) {
          throw new NotFoundException(__('Invalid list sh ex pain image'));
      }
      $this-&gt;set('listShExPainImage', $this-&gt;ListShExPainImage-&gt;read(null, $id));
  }
  </code></pre>
  
  <p>My add.ctp</p>
  
  <pre><code>&lt;?php echo $this-&gt;Form-&gt;create('ListShExPainImage');?&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;&lt;?php echo __('Add List Sh Ex Pain Image'); ?&gt;&lt;/legend&gt;
  &lt;?php
      echo $this-&gt;Form-&gt;input('name');
      echo $this-&gt;Form-&gt;input('image', array('type' =&gt; 'file'));
  ?&gt;
  &lt;/fieldset&gt;
  &lt;?php echo $this-&gt;Form-&gt;end(__('Submit'));?&gt;
  </code></pre>
  
  <p>My view.ctp</p>
  
  <pre><code>&lt;h2&gt;&lt;?php  echo __('List Sh Ex Pain Image');?&gt;&lt;/h2&gt;
  &lt;dl&gt;
      &lt;dt&gt;&lt;?php echo __('Id'); ?&gt;&lt;/dt&gt;
      &lt;dd&gt;
          &lt;?php echo h($listShExPainImage['ListShExPainImage']['id']); ?&gt;
          &amp;nbsp;
      &lt;/dd&gt;
      &lt;dt&gt;&lt;?php echo __('Name'); ?&gt;&lt;/dt&gt;
      &lt;dd&gt;
          &lt;?php echo h($listShExPainImage['ListShExPainImage']['name']); ?&gt;
          &amp;nbsp;
      &lt;/dd&gt;
      &lt;dt&gt;&lt;?php echo __('Image'); ?&gt;&lt;/dt&gt;
      &lt;dd&gt;
          &lt;?php echo h($listShExPainImage['ListShExPainImage']['image']); ?&gt;
          &amp;nbsp;
      &lt;/dd&gt;
  &lt;/dl&gt;
  </code></pre>
  
  <p></p>
  
  <p>Your help would be greatly appreciated, thanking you in advance.</p>