title: Joomla Development File Handling
body: <p>I'm making a simple MVC component for joomla following the hello world tutorial for the most part, with some some text fields and an image.</p>
  
  <p>The text fields save but the "file" field does not, any ideas?</p>
  
  <pre><code>**Controller:**
      &lt;?php
      // No direct access to this file
      defined('_JEXEC') or die('Restricted access');
  
      // import Joomla controllerform library
      jimport('joomla.application.component.controllerform');
  
      /**
       * MJob Controller
       */
      class MJobsControllerMJob extends JControllerForm
      {
      }
  
  **Model:**
  
      &lt;?php
      // No direct access to this file
      defined('_JEXEC') or die('Restricted access');
  
      // import Joomla modelform library
      jimport('joomla.application.component.modeladmin');
  
      class MJobsModelMJob extends JModelAdmin
      {
          public function getTable($type = 'MJob', $prefix = 'MJobsTable', $config = array()) 
          {
              return JTable::getInstance($type, $prefix, $config);
          }
  
          public function getForm($data = array(), $loadData = true) 
          {
              // Get the form.
              $form = $this-&gt;loadForm('com_mjobs.mjob', 'mjob', array('control' =&gt; 'jform', 'load_data' =&gt; $loadData));
  
              if (empty($form)) 
              {
                  return false;
              }
              return $form;
          }
  
          protected function loadFormData() 
          {
              // Check the session for previously entered form data.
              $data = JFactory::getApplication()-&gt;getUserState('com_mjobs.edit.mjob.data', array());
              if (empty($data)) 
              {
                  $data = $this-&gt;getItem();
              }
              return $data;
          }
      }
  
  **view.html.php:**
  
      &lt;?php
      // No direct access to this file
      defined('_JEXEC') or die('Restricted access');
  
      // import Joomla view library
      jimport('joomla.application.component.view');
  
      class MJobsViewMJob extends JView
      {
  
          public function display($tpl = null) 
          {
              // get the Data
              $form = $this-&gt;get('Form');
              $item = $this-&gt;get('Item');
  
              // Check for errors.
              if (count($errors = $this-&gt;get('Errors'))) 
              {
                  JError::raiseError(500, implode('&lt;br /&gt;', $errors));
                  return false;
              }
              // Assign the Data
              $this-&gt;form = $form;
              $this-&gt;item = $item;
  
              // Set the toolbar
              $this-&gt;addToolBar();
  
              // Display the template
              parent::display($tpl);
          }
  
          protected function addToolBar() 
          {
              JRequest::setVar('hidemainmenu', true);
              $isNew = ($this-&gt;item-&gt;id == 0);
              JToolBarHelper::title($isNew ? JText::_('COM_MJOBS_MANAGER_MJOB_NEW') : JText::_('COM_MJOBS_MANAGER_MJOB_EDIT'));
              JToolBarHelper::apply('mjob.apply');
              JToolBarHelper::save('mjob.save');
              JToolBarHelper::save2new('mjob.save2new');
              JToolBarHelper::cancel('mjob.cancel', $isNew ? 'JTOOLBAR_CANCEL' : 'JTOOLBAR_CLOSE');
          }
      }
  
  **VIEW (tmpl/edit.php):**
  &lt;?php
  // No direct access
  defined('_JEXEC') or die('Restricted access');
  JHtml::_('behavior.tooltip');
  echo "&lt;b&gt;MJOB EDIT START&lt;/b&gt;&lt;br&gt;";
  ?&gt;
  &lt;form action="&lt;?php echo JRoute::_('index.php?option=com_mjobs&amp;layout=edit&amp;id='.(int) $this-&gt;item-&gt;id); ?&gt;"
        method="post" enctype="multipart/form-data" name="adminForm" id="mjob-form"&gt;
      &lt;fieldset class="adminform"&gt;
          &lt;legend&gt;&lt;?php echo JText::_( 'COM_MJOBS_MJOB_DETAILS' ); ?&gt;&lt;/legend&gt;
          &lt;ul class="adminformlist"&gt;
              &lt;?php foreach($this-&gt;form-&gt;getFieldset('details') as $field): ?&gt;
                  &lt;li&gt;&lt;?php echo $field-&gt;label;echo $field-&gt;input;?&gt;&lt;/li&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/ul&gt;
      &lt;/fieldset&gt;
      &lt;div&gt;
          &lt;input type="hidden" name="task" value="mjob.edit" /&gt;
          &lt;?php echo JHtml::_('form.token'); ?&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>