<?php
/**
* LandofCoder
*
* NOTICE OF LICENSE
*
* This source file is subject to the landofcoder.com license that is
* available through the world-wide-web at this URL:
* https://landofcoder.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category LandofCoder
* @package Lofmp_Blog
* @copyright Copyright (c) 2022 Landofcoder (https://landofcoder.com/)
* @license https://landofcoder.com/LICENSE-1.0.html
*/
declare(strict_types=1);
namespace Lofmp\Blog\Controller\Adminhtml\Upload\Image;
use Magento\Framework\Controller\ResultFactory;
/**
* Blog image upload controller
*/
abstract class Action extends \Magento\Catalog\Controller\Adminhtml\Category\Image\Upload
{
/**
* File key
*
* @var string
*/
protected $_fileKey;
public function execute()
{
try {
$result = $this->imageUploader->saveFileToTmpDir($this->_fileKey);
$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);
}
}
|