2018-06-13 14:15
浏览 41


I am new to Codeigniter and new to the MVC webdesign, i have plant insert form i want to upload image and save image name into database i tried many codes but not works please help me to write upload function

plant insert form is below here

    <?php echo validation_errors(); ?>
    <?php echo form_open('AddPlant/InsertPlant')?>
        <div class="form-group has-error">
            <label for="name">Name <span class="require">*</span></label>
            <input type="text" class="form-control" name="name" />

        <div class="form-group">
            <label for="description">Description</label>
            <textarea rows="5" class="form-control" name="description" > 
        <div class="form-group required">
           <label for="exampleSelect1" class='control-label'>Job Type</label>
           <select class="form-control" id="age" name="age">
            <option value="1">Level 1</option>
            <option value="2">Level 2</option>
            <option value="3">Level 3</option>
        <div class="form-group">
            <p><span class="require">*</span> - required fields</p>
        <div class="form-group">
            <label for="description">Plant Image</label>
            <input type="file" name="plantimg">
        <div class="form-group">
            <button type="submit" class="btn btn-primary">
            <button class="btn btn-default">

    <?php echo form_close();?>

My Codeigniter model

       class Model_plants extends CI_Model

     function insertPlantData(){

    $data =array(

        'name'=> $this->input->post('name',TRUE),
        'description'=> $this->input->post('description',TRUE),
         'age'=> $this->input->post('age',TRUE),

    return $this->db->insert('plants',$data);

1条回答 默认 最新

相关推荐 更多相似问题