![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/amasty/shopby/Controller/Adminhtml/Category/Image/ |
<?php /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Improved Layered Navigation Base for Magento 2 */ namespace Amasty\Shopby\Controller\Adminhtml\Category\Image; use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Category; use Magento\Framework\Controller\ResultFactory; use Magento\Backend\App\Action\Context as ActionContext; use Magento\Catalog\Model\ImageUploader; class Upload extends Action { /** * @var \Magento\Catalog\Model\ImageUploader */ protected $imageUploader; /** * Upload constructor. * * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Model\ImageUploader $imageUploader */ public function __construct( ActionContext $context, ImageUploader $imageUploader ) { parent::__construct($context); $this->imageUploader = $imageUploader; } /** * Upload file controller action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { try { $files = $this->getRequest()->getFiles(); $result = $this->imageUploader->saveFileToTmpDir(key((array)$files)); $result['cookie'] = [ 'name' => $this->_getSession()->getName(), 'value' => $this->_getSession()->getSessionId(), 'lifetime' => $this->_getSession()->getCookieLifetime(), 'path' => $this->_getSession()->getCookiePath(), 'domain' => $this->_getSession()->getCookieDomain(), ]; } catch (\Exception $e) { $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()]; } return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result); } /** * {@inheritdoc} */ protected function _isAllowed() { return $this->_authorization->isAllowed(Category::ADMIN_RESOURCE); } }