title: How can i upload image from front-end in magento?
body: <p>I am trying to upload single image from front-end in my custom module. This is my form in test/template/test.phtml </p>
  
  <pre><code>&lt;form action="&lt;?php echo Mage::getUrl('text/index/save') ?&gt;" method="post" enctype="multipart/form-data"&gt;
  &lt;label for="sb_link"&gt;Image&lt;/label&gt;
  &lt;input type="file" id="bs_image" name="bs_image" required="true"/&gt;
  &lt;input type="submit" value="Submit" /&gt;
  </code></pre>
  
  <p> 
  Here is my controller where i am uploading images in media folder and saving name in databse.</p>
  
  <pre><code>&lt;?php
  
  public function saveAction() {
      echo $path = Mage::getBaseDir() . '/test';
      if (!file_exists($path)) {
          mkdir($path, 777, true);
      }
      try {
          $fname = $_FILES['test']['name'];
          $uploader = new Varien_File_Uploader('test');
          $uploader-&gt;setAllowedExtensions(array('png', 'gif', 'jpeg', 'docx'));
          $uploader-&gt;setAllowCreateFolders(true);
          $uploader-&gt;setAllowRenameFiles(false);
          $uploader-&gt;setFilesDispersion(false);
          $uploader-&gt;save($path, $fname);
      } catch (Exception $e) {
          echo 'Error Message: ' . $e-&gt;getMessage();
      }
  
  
      $contact = Mage::getModel('test/test');
      $contact-&gt;setData('bs_image', $bs_image);
      $contact-&gt;save();
  
      $this-&gt;_redirectReferer();
  }
  </code></pre>
  
  <p>I am getting this error.Error Message: File was not uploaded. 
  Thanks  </p>