I have created a custom module in which I have created a form like this

    <form action="<?php echo $this->getUrl('AdminSample/sampleOne/index');?>" method="post" enctype="multipart/form-data">
<table id="views" width="900px">
    <td>View 1:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload1" id="fileToUpload" required ></td> 
    <td>View 2:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload2" id="fileToUpload" required></td>
    <td>View 3:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload3" id="fileToUpload" required></td>
    <td>View 4:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload4" id="fileToUpload" required></td>
    <td>View 5:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload5" id="fileToUpload" required></td>
    <td>View 6:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload6" id="fileToUpload" required></td>
    <td>View 7:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload7" id="fileToUpload" required></td>
    <td>View 8:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload8" id="fileToUpload" required></td>
    <td>View 9:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload9" id="fileToUpload" required></td>
    <td>View 10:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload10" id="fileToUpload" required></td>
    <td>View 11:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload11" id="fileToUpload" required></td>
    <td>View 12:</td>
        <td><input data-form-part="product_form" type="file" name="fileToUpload12" id="fileToUpload" required></td>

<h2>Parts & Colors</h2>
    <input type="button" onclick="addTable()" value="Add Part">
<div id="divResults">

<button type="submit">Save</button>

and i have called custom controller, but i'm getting redirect to admin dashboard. Is there anything wrong in this code? Please help me to get all images descriptions like name, tmp_name, size and type?

Please ask, If any additional information required to anyone.

This is custom controller i write

namespace Tym17\AdminSample\Controller\Adminhtml\SampleOne;

class Index extends \Magento\Backend\App\Action
  * Index Action*
  * @return void

    protected $resultRawFactory;

        public function __construct(\Magento\Backend\App\Action\Context $context) {
  public function execute()

    echo "one";
  • have u create acl.xml – Amit Bera Apr 19 '17 at 14:33

Seem that you're missing the form key:

<input name="form_key" type="hidden" value="<?php /* @escapeNotVerified */ echo $block->getFormKey(); ?>" />
  • Still redirecting to admin dashboard – Mandar Parbate Apr 20 '17 at 10:17
  • This url $this->getUrl('AdminSample/sampleOne/index') is available? Working? Should try to die() in this controller. – Khoa TruongDinh Apr 20 '17 at 10:21
  • yes it working fine – Mandar Parbate Apr 20 '17 at 10:32
  • i'm getting the whole URL – Mandar Parbate Apr 20 '17 at 10:33
  • if i uses GET instated of POST it works fine and i get redirect to that controller, but i only get the name of the image not the images details. – Mandar Parbate Apr 20 '17 at 10:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.