I created a form to add products in the frontend, and I've added products with all attributes, except for product image. When I save, it shows: Image does not exist. Please help me find the problem. Thanks.
My template:
<div class="field name-image">
<label class="required"><em>*</em><?php echo $this->__('Image') ?></label>
<div class="input-box">
<input type="file" id="<?php echo $this->getFieldId('image')?>" name="image title="<?php echo Mage::helper('core')->quoteEscape($this->getStoreLabel('image')) ?>" />
</div>
</div>
In controller:
$product = new Mage_Catalog_Model_Product();
$filename = $_FILES['image']['name'];
$image = Mage::getBaseDir('media') . DS . "catalog\product" . DS . $filename;
$product ->setMediaGallery(array('images' => array(), 'values' => array()))
->addImageToMediaGallery($image, array('image', 'small_image', 'thumbnail'), false, false);
$product->save();