0

在 PHP 中,我正在使用一些数据插入文件上传我的表单看起来像这样

 <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" />
    <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."/";

现在为了插入值,我正在执行此代码。

if(isset($_POST['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)) {
   echo "Incorrent file extension, Please Use png,jpg or gif files only";
      } else {
      if(mysql_query('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)) {
         echo "Settings updated successfully";
        } else {
        echo "You Have Some Errors";
          }
        }
      }
}

在单击按钮后,此处的值已成功存储到数据库中,Add Store Configuration但我仍然收到 You Have Some Errors我在表单中设置的错误。它应该显示设置已成功更新。有人能告诉我这是怎么回事吗?

4

0 回答 0