I am uploading images in my module using the folowing code at:
\Block\Adminhtml\Visualcolor\Edit\Tab\Form.php
$fieldset->addField('image', 'image', array(
label' => Mage::helper('visualcolor')->__('Image'),
'required' => false,
'name' => 'image',
));
then I save it fine at the controller into my specific folder at media and works fine.
$path = Mage::getBaseDir('media') . DS . "visualcolors" . DS;
$uploader->save($path, $_FILES['image']['name']);
The problem it is how do i get the correct path in the form.php instead the default "media" folder?
Best Answer
You need a custom form element for the image field.
So create this file:
app/code/local/[Namespace]/[Module]/Block/Adminhtml/Visualcolor/Helper/Image.php
now in your
Block\Adminhtml\Visualcolor\Edit\Tab\Form.php
file tell magento to use your block as the renderer for image fields.Add this line of code right below
$fieldset = $form->addFieldset(....);