dongxibeng5324 2017-02-02 09:44
浏览 49

如何将文件图像存储到mysql(Codeigniter)

I tried to upload file images into mysql using Codeigniter

This is likely my upload view:

<label>Upload File</label>
    <input type="file" class="form-control" name="images">
</div>

I've done with image name, description, etc.

I tried to save it into database, just like normal input form.

The result, column "images" cannot be null. I have set column "images" with varbinary(3000)

Am I doing it wrong?

EDITED:

My Controller:

public function save(){
    $this->gallery_model->save_foto();
    $this->session->set_flashdata('msg','FOTO BERHASIL DI UPLOAD');
    redirect(base_url('gallery'));
}

My Model

<?php
class Gallery_model extends CI_Model {
      public function __construct() {
        parent::__construct();
      }

  public function save_foto(){
    $data['id']            = date('U');
    $data['nm_foto']       = $this->input->post('nm_foto');
    $data['username']      = $this->input->post('username');
    $data['tanggal']       = date('j F Y');
    $data['images']        = $this->input->post('images');
    $data['deskripsi']     = $this->input->post('deskripsi');
    $this->db->insert( 'gallery', $data );
  }
}
  • 写回答

4条回答 默认 最新

  • doudou3213 2017-02-02 09:59
    关注

    You can't directly upload image into database , Insert image path

    For upload image form form add

    enctype="multipart/form-data" 
    

    in form .

    For more help regarding image upload in codeigniter

    Codeigniter Image Upload

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?