Public Member Functions | |
uploadAction () | |
Protected Member Functions | |
_isAllowed () |
Definition at line 34 of file FileController.php.
_isAllowed | ( | ) | [protected] |
Check admin permissions for this controller
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 76 of file FileController.php.
00077 { 00078 return Mage::getSingleton('admin/session')->isAllowed('catalog/products'); 00079 }
uploadAction | ( | ) |
Upload file controller action
Definition at line 40 of file FileController.php.
00041 { 00042 $type = $this->getRequest()->getParam('type'); 00043 $tmpPath = ''; 00044 if ($type == 'samples') { 00045 $tmpPath = Mage_Downloadable_Model_Sample::getBaseTmpPath(); 00046 } elseif ($type == 'links') { 00047 $tmpPath = Mage_Downloadable_Model_Link::getBaseTmpPath(); 00048 } elseif ($type == 'link_samples') { 00049 $tmpPath = Mage_Downloadable_Model_Link::getBaseSampleTmpPath(); 00050 } 00051 $result = array(); 00052 try { 00053 $uploader = new Varien_File_Uploader($type); 00054 $uploader->setAllowRenameFiles(true); 00055 $uploader->setFilesDispersion(true); 00056 $result = $uploader->save($tmpPath); 00057 $result['cookie'] = array( 00058 'name' => session_name(), 00059 'value' => $this->_getSession()->getSessionId(), 00060 'lifetime' => $this->_getSession()->getCookieLifetime(), 00061 'path' => $this->_getSession()->getCookiePath(), 00062 'domain' => $this->_getSession()->getCookieDomain() 00063 ); 00064 } catch (Exception $e) { 00065 $result = array('error'=>$e->getMessage(), 'errorcode'=>$e->getCode()); 00066 } 00067 00068 $this->getResponse()->setBody(Zend_Json::encode($result)); 00069 }