Public Member Functions | |
uploadAction () | |
Protected Member Functions | |
_isAllowed () |
Definition at line 34 of file GalleryController.php.
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 64 of file GalleryController.php.
00065 { 00066 return Mage::getSingleton('admin/session')->isAllowed('catalog/products'); 00067 }
uploadAction | ( | ) |
Definition at line 36 of file GalleryController.php.
00037 { 00038 $result = array(); 00039 try { 00040 $uploader = new Varien_File_Uploader('image'); 00041 $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png')); 00042 $uploader->setAllowRenameFiles(true); 00043 $uploader->setFilesDispersion(true); 00044 $result = $uploader->save( 00045 Mage::getSingleton('catalog/product_media_config')->getBaseTmpMediaPath() 00046 ); 00047 00048 $result['url'] = Mage::getSingleton('catalog/product_media_config')->getTmpMediaUrl($result['file']); 00049 $result['file'] = $result['file'] . '.tmp'; 00050 $result['cookie'] = array( 00051 'name' => session_name(), 00052 'value' => $this->_getSession()->getSessionId(), 00053 'lifetime' => $this->_getSession()->getCookieLifetime(), 00054 'path' => $this->_getSession()->getCookiePath(), 00055 'domain' => $this->_getSession()->getCookieDomain() 00056 ); 00057 } catch (Exception $e) { 00058 $result = array('error'=>$e->getMessage(), 'errorcode'=>$e->getCode()); 00059 } 00060 00061 $this->getResponse()->setBody(Zend_Json::encode($result)); 00062 }