title: "File was not uploaded" magento error even file is uploaded to particular folder
body: <p>I am making an application in which i am uploading file from my custom tab as follows</p>
  
  <p><img src="https://i.stack.imgur.com/qMeqY.png" alt="enter image description here"></p>
  
  <p>i created a observer for event called <code>catalog_product_save_after</code>. In the particular function, i am uploading those files to catalog/product folder and its get uploaded to those folder without any error.</p>
  
  <p>But when i am trying to assign those images to that particular product, i got the following error.
  <code>File was not uploaded</code> at file <code>E:\xampp\htdocs\magento\lib\Varien\File\Uploader.php on line 152</code></p>
  
  <p>If i check <code>system.log</code> then i see the <code>2012-08-24T11:33:15+00:00 ERR (3): User Error: Some transactions have not been committed or rolled back  in E:\xampp\htdocs\magento\lib\Varien\Db\Adapter\Pdo\Mysql.php on line 3645</code> this error.</p>
  
  <p>My observer function is as follows</p>
  
  <pre><code>public function Savedata($observer)
      {
          $params     =   Mage::app()-&gt;getRequest()-&gt;getParams();
  
          $product    =   $observer-&gt;getEvent()-&gt;getProduct();
  
          $product_id =   $product-&gt;getId();
  
  
          $filesData  =   array();
  
  
          $keysData   =   array_keys($_FILES);
  
  
          foreach($keysData as $keys)
          {
              $uploader = new Varien_File_Uploader("$keys");
              $uploader-&gt;setAllowedExtensions(array('jpeg', 'jpg', 'png', 'tiff'));
              $uploader-&gt;setAllowRenameFiles(true);
              $uploader-&gt;setFilesDispersion(false);
  
              $path = Mage::getBaseDir('media') . DS  . "catalog" . DS . "product";
  
              if(!is_dir($path))
              {
                  mkdir($path);
              }
  
              $extension  =   pathinfo($_FILES["$keys"]['name'], PATHINFO_EXTENSION);
  
              $date = new DateTime();
  
              $file_name                  =   $keys . "_" . $product_id . "." . $extension;
  
              $_FILES["$keys"]['name']    =   $file_name;
  
              $uploader-&gt;save($path, $_FILES["$keys"]['name']);
              $filesData[]    =   $path .DS. $_FILES["$keys"]['name'];
          }
  
          print_r($filesData);
          ///till this works file.. when i add following code, program dies. 
  
          try 
          {
              $productData = Mage::getModel('catalog/product')-&gt;load($product_id);
  
              print_r($productData-&gt;getData());
  
  
              foreach($filesData as $file)
              {
                  $productData-&gt;addImageToMediaGallery($file, "image" ,false, false);
              }
              $productData-&gt;save();
  
              $productData = Mage::getModel('catalog/product')-&gt;load($product_id);
  
              print_r($productData-&gt;getData());
          }
          catch (Exception $e)
          {
              echo $e-&gt;getMessage() . "||" . $e-&gt;getCode() . "||" . $e-&gt;getFile() . "||" . $e-&gt;getLine();
          }
  
  
          exit();
      }
  </code></pre>
  
  <p>any suggestion where i am going wrong? why this error occur?</p>
  
  <p>i am using magento 1.7</p>