title: Magento image upload problem
body: <p>Thanks in advance.</p>
  
  <p>I am new to Magento, and I have created a module that directly shows products to the front of Magento.</p>
  
  <p>In this module, I have created a form in customer account section where customers can fill out necessary data for product. Product data is saved successfully but I can't see the image on front. I have checked all the things the uploaded product from customer section also go to admin section for approval.</p>
  
  <p>I just want to show image of product which I upload. My code is as follows for product save and image upload.</p>
  
  <p>Sorry for my English.</p>
  
  <p>-Jeet</p>
  
  <pre><code>$magentoProductModel = Mage::getModel('catalog/product');
  $magentoProductModel-&gt;setWebsiteIds(array(Mage::app()-&gt;getStore()-&gt;getId()));
  $magentoProductModel-&gt;setAttributeSetId(4);//old
  //$magentoProductModel-&gt;setAttributeSetId(1);
  $magentoProductModel-&gt;setTypeId('simple');
  $magentoProductModel-&gt;setName($data[name]);
  $magentoProductModel-&gt;setDescription($data[description]);
  $magentoProductModel-&gt;setPrice($data[price]);
  $magentoProductModel-&gt;setShortDescription($data[short_description]);
  $magentoProductModel-&gt;setWeight($data[weight]);
  $magentoProductModel-&gt;setStatus(1);
  $magentoProductModel-&gt;setCategoryIds(array(3));
  $magentoProductModel-&gt;setTaxClassId('None');
  //$magentoProductModel-&gt;setSku('rand-sku-' .rand(1,20000) );
  
  /* upload product image*/
  $customerProductId=34;
  $mediDir = Mage::getBaseDir('media');
  $imagesdir = $mediDir . '/customersproducts/' . $customerProductId . '/';
  
  if(!file_exists($imagesdir)){ 
      return false;
  }
  
  foreach (new DirectoryIterator($imagesdir) as $fileInfo) {
      //print_r($fileInfo);
  
      if($fileInfo-&gt;isDot() || $fileInfo-&gt;isDir()) continue;
  
      if($fileInfo-&gt;isFile()) {
          //echo $fileInfo-&gt;getPathname();         
          $magentoProductModel-&gt;addImageToMediaGallery($fileInfo-&gt;getPathname(),array('image','small_image','thumbnail'), true, false, true);
      }
      //else {
          //echo "no";
      //}
  }
  print_r($magentoProductModel);
  
  /*upload script end */
  
  
  $saved = $magentoProductModel-&gt;save();
  $lastId = $saved-&gt;getId();
  $customerProduct = Mage::getModel('customerpartner/customerpartner_product')-&gt;load($lastId);
  $customerProduct-&gt;setProductId($lastId);
  $logged_in_user=Mage::getSingleton('customer/session')-&gt;getCustomer()-&gt;getId();
  $customerProduct-&gt;setCustomerId($logged_in_user);
  $customerProduct-&gt;setCustomerId();
  $customerProduct-&gt;save();
  </code></pre>