Magento – Image doesn’t upload in custom module magento

imagePHP

I have created custom module in magento with image upload attribute. Image name was successfully stored in DB table. But image doesn't upload to the target folder.

I have tried with this following code. please show me "what am i doing wrong here"

 $uploader = new Varien_File_Uploader('fileinputname');
 $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
 $uploader->setAllowRenameFiles(false);
 $uploader->setFilesDispersion(false);

 $path = Mage::getBaseDir('media') .DS. 'foo'.DS ;
 $uploader->save($path, $_FILES['fileinputname']['name']);

Best Answer

I just edit file path like

 $path = Mage::getBaseDir('media').'/foo/';

instead of

$path = Mage::getBaseDir('media') .DS. 'foo'.DS ;

That's All. Now Its working well

For further details please lookout this post

Related Topic