title: File Upload not working in Magento from custom admin module
body: <p>I created a custom admin module in magento. The module has a form which on submitting posts to a controller which handles the file upload. </p>
  
  <p>I am getting the following error on submitting the form:</p>
  
  <pre><code>a:5:{i:0;s:22:"File was not uploaded.";i:1;s:1030:"#0 C:\wamp\www\magento-PhpDevGuide-packt\app\code\local\Endosoft\Categoryupdate\controllers\Adminhtml\CategoryupdateController.php(11): Varien_File_Uploader-&gt;__construct('uploadcsv')
  #1 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Endosoft_Categoryupdate_Adminhtml_CategoryupdateController-&gt;formPostAction()
  #2 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action-&gt;dispatch('formpost')
  #3 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard-&gt;match(Object(Mage_Core_Controller_Request_Http))
  #4 C:\wamp\www\magento-PhpDevGuide-packt\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front-&gt;dispatch()
  #5 C:\wamp\www\magento-PhpDevGuide-packt\app\Mage.php(684): Mage_Core_Model_App-&gt;run(Array)
  #6 C:\wamp\www\magento-PhpDevGuide-packt\index.php(87): Mage::run('', 'store')
  #7 {main}";s:3:"url";s:78:"/index.php/admin/categoryupdate/formpost/key/d91e6825136ce2206d7c72bbd1b7af34/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
  </code></pre>
  
  <p>Here is the form:</p>
  
  <pre><code>&lt;?php $url = Mage::helper("adminhtml")-&gt;getUrl('adminhtml/categoryupdate/formpost'); ?&gt;
  &lt;h4&gt;Upload Your CSV&lt;/h4&gt;
  &lt;form action="&lt;?php echo $url ?&gt;" method="post" enctype="multipart/form-data"&gt;
      &lt;p&gt;&lt;input name="form_key" type="hidden" value="&lt;?php echo Mage::getSingleton('core/session')-&gt;getFormKey() ?&gt;" /&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type="file" name="csvupload" /&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type="submit" name="submit" value="Submit" /&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the controller method:</p>
  
  <pre><code>public function formPostAction() {
    $uploader = new Varien_File_Uploader('uploadcsv');
    $uploader-&gt;setAllowedExtensions(array('json'));
    $uploader-&gt;setAllowRenameFiles(false);
    $uploader-&gt;setFilesDispersion(false);
    $path = Mage::getBaseDir('media');
    $fileName = $_FILES['uploadcsv']['name'];
    $uploader-&gt;save($path, $fileName);
  
    $this-&gt;loadLayout();
    $this-&gt;renderLayout();
  }
  </code></pre>
  
  <p>I could not understand why the file is not uploaded.</p>
  
  <p>Could someone please clarify what is going wrong?</p>
  
  <p><strong>Additional Info:</strong></p>
  
  <ul>
  <li>Instead of using magento form container and form i am using my own form by calling a phtml file from the layout..</li>
  </ul>