代码之家  ›  专栏  ›  技术社区  ›  scrot

CodeIgniter-通过表单上传图像,将图像的位置存储在数据库中

  •  7
  • scrot  · 技术社区  · 17 年前

    我正试图通过表单将图像上传到我的站点,但是将图像的位置存储在数据库中(而不是使数据库陷入困境)效率更高。

    我的表格有问题,真的不知道该去哪里:

    <?=form_open('bro/submit_new');?>
     //other form data
     Image: <input type="file" name="image" size="20" /> <br>
     <input type="submit" value="Submit" />
    </form>
    

    谢谢

    编辑:控制器代码(此部件):

    function submit_new(){
        $config['upload_path'] = './images/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '2000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';     
        $this->load->library('upload', $config);
    
        $this->db->insert('post', $_POST);
    
        redirect('bro');
    }
    
    3 回复  |  直到 17 年前
        1
  •  8
  •   victoriah    17 年前

    CodeIgniter的文件上传类将为您完成此任务。这个 entry in their user guide 尽我所能解释清楚了,所以我要告诉你。

        2
  •  8
  •   joomla master joomla master    17 年前

    使用form_open_multipart()而不是form_open()

        3
  •  -1
  •   abcdef    13 年前

    推荐文章