![]() 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/cartforge.co/app/code/Amasty/Label/Controller/Adminhtml/Label/Edit/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Product Labels for Magento 2 */ namespace Amasty\Label\Controller\Adminhtml\Label\Edit; use Amasty\Label\Controller\Adminhtml\Label\Edit; use Exception; use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context as AdminActionContext; use Magento\Catalog\Model\ImageUploader; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\ResultFactory; class UploadImage extends Action implements HttpPostActionInterface { public const ADMIN_RESOURCE = Edit::ADMIN_RESOURCE; /** * @var ImageUploader */ protected $imageUploader; public function __construct( AdminActionContext $context, ImageUploader $imageUploader ) { parent::__construct($context); $this->imageUploader = $imageUploader; } public function execute() { $imageId = $this->_request->getParam('param_name', 'image'); try { $result = $this->imageUploader->saveFileToTmpDir($imageId); } catch (Exception $e) { $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()]; } return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result); } }