【问题标题】:jQuery multiple image uploader insert in to database?jQuery多图像上传器插入数据库?
【发布时间】:2010-10-15 11:56:51
【问题描述】:

我目前在 CI 中为我的表单使用 jQuery 的多图像上传器。这非常有效,但是我想将文件名等插入数据库 - 有人知道我该怎么做吗?

我的控制器

$config['upload_path']   = './uploads/';
$config['allowed_types'] = 'gif|jpg|pdf|doc|bmp|png';
$config['max_size']      = '2024';
$config['max_width']     = '1024';
$config['max_height']    = '768';

$this->load->library('upload', $config);
$this->load->library('Multi_upload');

$files = $this->multi_upload-go_upload();
$data = array('upload_data' => $files); 

我的观点

<input type="file" name="images[]" size="20" class="multi" id="images" maxlength="5" /> 

任何帮助都会很棒,谢谢。

【问题讨论】:

    标签: jquery database codeigniter


    【解决方案1】:

    我不知道 $this->multi_upload->go_upload() 返回什么,但是如果它返回一个上传文件的数组,你只需要执行一个 foreach 和一个 sql insert。

    foreach($files as $file)
    {
        $insert = array(
            'filename' => $file["name"],
            'type' => $file["type"]
        );
    
        $this->db->insert('table', $insert);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-05
      • 2010-09-23
      • 1970-01-01
      • 2018-05-23
      相关资源
      最近更新 更多