codeigniter ajax图片上传

I was following a tutorial that teaches how to to upload image with ajax and CodeIgniter. But i kind of run into INTERNAL SERVER ERROR each time i tried to run the code.i have checked the folder where i suppose the image get uploaded to but it was empty. Tried all i could to get this thing working but it appears i can't. So, i would like someone check these codes out for me.

CONTROLLER

    public function upload_image()
    {
        $data['title'] = 'Codeigniter Image upload';
        $this->load->view('image_upload', $data);
    }

    public function ajax_upload()
    {
        if (isset($_FILES["image_file"]["name"])) {
            $config['upload_path']  = './uploads/';
            $config['allowed_types'] = 'jpeg|gif|jpg|png';
            $this->load->library('upload', $config);
            if (!$this->upload->do_upload('image_file')) {
                echo '<p class="text-danger">'.$this->upload->display_errors().'</p>';
            } else {
                $data = $this->upload->data();
                 $config['image_library'] = 'gd2';
                 $config['source_image'] = './uploads/'.$data["file_name"];
                $config['create_thumb'] = FALSE;
                $config['maintain_ratio'] = FALSE;
                $config['quality'] = '60%';
                $config['width'] = 200;  
                $config['height'] = 200;
                $config['new_image'] = './uploads/'.$data["file_name"];
                // load image library
                $this->load->library('image_lib', $config);
                $this->image_lib->resize();

                $img_data = array(
                    'name' => $data['file_name']
                    );
                $this->main_model->insert_img($img_data);
                echo $this->main_model->fetch_img();
            }
        } 
    }

Views file that contains the form

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>myschools | <?php echo $title; ?></title>
    <link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.min.css'); ?>">
    <!-- <link rel="stylesheet" href="<?php //echo base_url('assets/css/custom.css'); ?>"> -->
</head>
<body>
  <div class="container">
    <h3 align="center"><?php echo $title; ?></h3><br>

    <form class="form-inline" role="form" align="center" id="upload_form" method="post" enctype="multipart/form-data">

      <div class="form-group">
        <label class="sr-only" for="image_file">Select Image</label>
        <input type="file" class="form-control" id="image_file" name="image_file">
      </div>
      <button type="submit" class="btn btn-info">Upload</button>
  </form>
  <br>
  <br>
  <br>
  <div id="uploaded_image"></div>
  </div>
<script src="<?php echo base_url('assets/js/jquery.min.js'); ?>"></script>
<script src="<?php echo base_url('assets/js/bootstrap.min.js'); ?>"></script>

</body>
</html>