Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在codeIgniter中使用ajax发送表单数据和输入类型文件_Php_Jquery_Ajax_Codeigniter_Multipartform Data - Fatal编程技术网

Php 在codeIgniter中使用ajax发送表单数据和输入类型文件

Php 在codeIgniter中使用ajax发送表单数据和输入类型文件,php,jquery,ajax,codeigniter,multipartform-data,Php,Jquery,Ajax,Codeigniter,Multipartform Data,我有一个简单的表单,其中包括输入类型文件和其他表单字段。我可以将输入类型文件数据发送到控制器,但在发送其他表单数据和输入类型文件时出现问题。 以下是我迄今为止所做的工作- 表格- 控制器功能- public function theme_options_data() { if(isset($_FILES['image_file']['name'])) { $this->load->helper('string');

我有一个简单的表单,其中包括输入类型文件和其他表单字段。我可以将输入类型文件数据发送到控制器,但在发送其他表单数据和输入类型文件时出现问题。
以下是我迄今为止所做的工作-
表格-

控制器功能-

public function theme_options_data()
 {
       if(isset($_FILES['image_file']['name']))
        {
          $this->load->helper('string');
          $logo_name=random_string('alnum',5);
          $config['upload_path']='./upload';
          $config['allowed_types']='jpg|jpeg|png|gif';
          $config['file_name']=$logo_name;
          $this->load->library('upload',$config);
          if(!$this->upload->do_upload('image_file'))
            {
              echo $this->upload->display_errors();
            }
            else
            {
              $data=$this->upload->data();
            }
          }

    }  
文件上传工作正常,但我只需要将表单数据(徽标大小、标题大小等)发送到控制器,然后我必须将所有数据存储到数据库。
请帮帮我。

谢谢

表单…输入字段名称

<form method="post" id="theme_option_form" enctype="multipart-formdata">
    Logo :<input type="file" name="image_file" id="image_file">
    Logo Size :<input type="text" name="logo_size" id="logo_size" class="form-control input-sm">
    Heading Size :<input type="text" name="hding_size" id="hding_size" class="form-control input-sm">
    <input type="submit" name="upload" id="upload" value="Upload" class="btn btn-primary btn-sm">

表单…输入字段名称

<form method="post" id="theme_option_form" enctype="multipart-formdata">
    Logo :<input type="file" name="image_file" id="image_file">
    Logo Size :<input type="text" name="logo_size" id="logo_size" class="form-control input-sm">
    Heading Size :<input type="text" name="hding_size" id="hding_size" class="form-control input-sm">
    <input type="submit" name="upload" id="upload" value="Upload" class="btn btn-primary btn-sm">

使用$\u POST['logo\u size']获取这些值,但您需要在输入文件中输入name=“logo\u size”$\u POST['logo\u size']获取这些值,但您需要在输入文件@Shailesh中输入name=“logo\u size”,谢谢您的帮助,它正在工作,但我有字体选择器从下拉列表中选择字体。我已经使用div创建了它,那么我该如何看待它的价值呢?@Shailesh感谢您的帮助,它正在工作,但我有字体选择器从下拉列表中选择字体。我已经使用div创建了它,那么我如何看待它的价值呢?
<form method="post" id="theme_option_form" enctype="multipart-formdata">
    Logo :<input type="file" name="image_file" id="image_file">
    Logo Size :<input type="text" name="logo_size" id="logo_size" class="form-control input-sm">
    Heading Size :<input type="text" name="hding_size" id="hding_size" class="form-control input-sm">
    <input type="submit" name="upload" id="upload" value="Upload" class="btn btn-primary btn-sm">
public function theme_options_data()
 {
       if(isset($_FILES['image_file']['name']))
        {
          $this->load->helper('string');
          $logo_name=random_string('alnum',5);
          $config['upload_path']='./upload';
          $config['allowed_types']='jpg|jpeg|png|gif';
          $config['file_name']=$logo_name;
          $this->load->library('upload',$config);
          if(!$this->upload->do_upload('image_file'))
            {
              echo $this->upload->display_errors();
            }
            else
            {
              $data=$this->upload->data();
            }
          }
       $logo_size = $_POST['logo_size'];
       $heading_size  = $_POST['hding_size'];
    }