0

4.3 admin custom controller redirecting to dashboard

<form enctype="multipart/form-data" method="post" action="<?php echo $block->getFormAction(); ?>" id="edit_form" X-Requested-With= "XMLHttpRequest">
    <input name="form_key" type="hidden" value="<?php echo $block->updateCancelTime() ?>" />
            <!--<input name="form_key" type="hidden" value="<?php //  echo $block->getFormKey() ?>" />-->
    <div id="base_fieldset" class="fieldset ">
        <table>
            <tbody>
                <tr>
                    <td class="value">
                        <p class="import_file_child">
                            <label for="import_file_src-upload">
                                Upload File: <input type="file" class="fileupload" required title="Select File to Import" name="import_file" id="import_file">
                            </label>
                        </p>
                    </td>
                </tr>
                <tr>
                    <td class="value">
                        <p class="form-buttons">
                            <input class="save" type="submit" title="Submit" id="upload_button" value="Import"/>
                        </p>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</form>

my save controller

 namespace Pawan\IntraImport\Controller\Adminhtml\Import;

//use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;

class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
    
//    protected $importer;
//    protected $formKeyValidator;
//    protected $directoryList;
//
//    public function __construct(
//        Context $context,
//        \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
//      
//        \Magento\Framework\Filesystem\DirectoryList $directoryList
//    ) {
//        $this->directoryList = $directoryList;
//      
//        $this->formKeyValidator = $formKeyValidator;
//        parent::__construct($context);
//    }

    /**
     * Save action
     *
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        die("test reached controller");

 }
}

when I click on import button it redirecting to dashboard expected it redirect save file and print data but nor printing in debug log getting

Request validation failed for action "Pawan\IntraImport\Controller\Adminhtml\Import\Save\Interceptor

any one help that would be very helpful for me.in 2.3 it working fine but after upgrade it not working

https://www.generacodice.com/en/articolo/2983658/magento-2.3-upgrade-breaks-http-post-requests-to-custom-module-endpoint

checked this link also but no luck

1
  • For help you to understand the real reason, please provide a full log from debug (exception). This error should come with exception. The error comes from \Magento\Framework\App\FrontController::processRequest Jun 21 at 20:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.