Jump to content

module after inserting the data successfully still showing error in frontent


Recommended Posts

Hi,

In prestashop I am doing a small module. In my module the form for upload an image is like this

 

  


 $this->_html .= '
    <form id="formID1" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data">
    <label for="">'.$this->l('Add Store Type').'</label>
    <input type="text" name="store_type" />


    <label for="">'.$this->l('Upload Your Custom Icon').'</label>
    <input type="FILE"  name="custom_icon" id="custom_icon" />


    <input type="submit" name="store_config" value="'.$this->l('Add Store Configuration').'" class="button" />
    </div>
    <form>';

    

    For uploading images I am doing a folder with 777 permission on it.

     


$uploaddir=dirname(__FILE__)."/storeconfig";
      if(!file_exists($uploaddir)) {
        mkdir($uploaddir, 777, true);
      }
       $tmpName=$uploaddir."/";

 

    Now for inserting values I am doing this code.

    


if(Tools::isSubmit('store_config')) {
    
      global $uploaddir;
      $custom_icon_name = time().$_FILES['custom_icon']['name'];
      $allowed_extensions = array('gif','jpg','png');
      $path_info = pathinfo($custom_icon_name);
      
      if( !in_array($path_info['extension'], $allowed_extensions)) {
        $this->_html .= $this->displayError($this->l('Incorrent file extension, Please Use png,jpg or gif files only'));
      } else {
      if(DB::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'store_config` (`store_config_id`,`store_type`,`custom_icon`) VALUES ("","'.$store_type.'","'.$custom_icon_name.'") ')) {
        if(move_uploaded_file($_FILES['custom_pin']['tmp_name'],$tmpName.$custom_icon_name)) {
          $this->_html .=$this->displayConfirmation($this->l('Settings updated successfully'));
        } else {
         $this->_html .= $this->displayError($this->l('You Have Some Errors'));
          }
        }
      }
    }

    

    Here the values are storing into the database successfully after doing click on button Add Store Configuration but still I am getting the error  You Have Some Errors which I have set in my form.It should show Settings updated successfully. Can someone tell me how this is error is comming?

 

    

 

Link to comment
Share on other sites

×
×
  • Create New...