How to set a default image in if user not defined in codeigniter
<p>My controller is but how I insert a default image name in database if user not upload any image when he/she input his details in form.</p>

<pre><code>&lt;?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Student extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this-&gt;load-&gt;model('student_model');
        $this-&gt;load-&gt;model('hostelinfo_model');
        $this-&gt;load-&gt;model('options_model');
        $this-&gt;load-&gt;model('upload_model');
        $this-&gt;load-&gt;library('form_validation');
        $this-&gt;load-&gt;library('upload');
    }

    public function index() {
        $this-&gt;form_validation-&gt;set_error_delimiters('&lt;div class="error"&gt;', '&lt;/div&gt;');
        $this-&gt;form_validation-&gt;set_rules('student_id', 'Student ID', 'required|trim|xss_clean|callback_student_id_check');
        $this-&gt;form_validation-&gt;set_rules('student_name', 'Student Name', 'required|trim|xss_clean');
        $this-&gt;form_validation-&gt;set_rules('father_name', 'Father Name', 'required|trim|xss_clean');
        $this-&gt;form_validation-&gt;set_rules('program_name', 'Progrem Name', 'required|trim|xss_clean');
        $this-&gt;form_validation-&gt;set_rules('mobile', 'Mobile No', 'required|trim|xss_clean|is_unique[student.mobile]|max_length[11]|min_length[11]');
        $this-&gt;form_validation-&gt;set_rules('email', 'Email ID', 'trim|xss_clean|is_unique[student.email]|valid_email');
        $this-&gt;form_validation-&gt;set_rules('hostel_name', 'Hostel Name', 'required|trim|xss_clean');
        if ($this-&gt;form_validation-&gt;run() == FALSE) {
            $this-&gt;load-&gt;view('header1');
            $this-&gt;load-&gt;view('book_hostel');
            $this-&gt;load-&gt;view('footer');
        } else {
           $config['upload_path'] = 'uploads';
           $config['allowed_types'] = 'jpeg|jpg|png';
           $config['max_size'] = '2048';
           $config['encrypt_name'] = true;
           $this-&gt;upload-&gt;initialize($config);
           if (!$this-&gt;upload-&gt;do_upload('image_name')) {
               $image_data = "noimage.png";
               $data['error'] = $this-&gt;upload-&gt;display_errors();
                   $this-&gt;load-&gt;view('header');
                   $this-&gt;load-&gt;view('book_hostel', $data);
                   $this-&gt;load-&gt;view('footer');
            }else{
               $this-&gt;form_validation-&gt;set_rules('image_name', 'Upload Image', 'trim|xss_clean');
               if ($this-&gt;form_validation-&gt;run($this) == FALSE) {
                   $data['error'] = '';
                   $this-&gt;load-&gt;view('header1');
                   $this-&gt;load-&gt;view('book_hostel', $data);
                   $this-&gt;load-&gt;view('footer');
                }
            }
                $image_data = $this-&gt;upload-&gt;data();
                $data = array(
                'image_name' =&gt; $image_data['file_name'],
                'student_id' =&gt; $this-&gt;input-&gt;post('student_id'),
                'student_name' =&gt; $this-&gt;input-&gt;post('student_name'),
                'father_name' =&gt; $this-&gt;input-&gt;post('father_name'),
                'program_name' =&gt; $this-&gt;input-&gt;post('program_name'),
                'mobile' =&gt; $this-&gt;input-&gt;post('mobile'),
                'email' =&gt; $this-&gt;input-&gt;post('email'),
                'hostel_name' =&gt; $this-&gt;input-&gt;post('hostel_name')

            );
            $this-&gt;student_model-&gt;form_insert($data);
            //$this-&gt;sendEmail();
            $data['message'] = 'Data Inserted Successfully';
            redirect('hostel');

         }
    }
}
</code></pre>