I have Created one custom module to upload file and its display in database but it is not appear in upload folder
so how can i solve this
here my code
$path = Mage::getBaseDir() . '/test';
if (!file_exists($path))
{
mkdir($path, 777, true);
try
{
$sleeve = $_FILES['sleeve']['name'];
$uploader = new Varien_File_Uploader('test');
$uploader->setAllowedExtensions(array('png', 'gif', 'jpeg', 'docx'));
$uploader->setAllowCreateFolders(true);
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$uploader->save($path, $sleeve);
}
catch (Exception $e)
{
echo 'Error Message: ' . $e->getMessage();
}
}
$pid = ''.$this->getRequest()->getPost('pid');
$front = ''.$this->getRequest()->getPost('front');
$sleeve = $_FILES['sleeve']['name'];
if(isset($pid)&&($pid!='') && isset($sleeve)&&($sleeve!='')
&& isset($front)&&($front!='') )
{
$contact = Mage::getModel('custom/custom');
$contact->setData('product_id', $product_id);
$contact->setData('sleeve', $sleeve);
$contact->setData('front', $front);
$contact->save();
}
$this->_redirect('myown/index/index');
}
}
Aucun commentaire:
Enregistrer un commentaire