$ _FILES数据始终为null

I'm trying to post a PNG image. Here is my code.

<form action="http://killprashanth.res.cmu.edu/index.php/main/post"  enctype="multipart/form-data" method="post" accept-charset="utf-8"> 
<div class="hidden"> 
 <input type="hidden" name="userid" value="" /> 
 <input type="hidden" name="thread" value="" /> 
</div>
<label for="text">Message text:</label>
<textarea name="text" cols="90" rows="12" ></textarea><br>
<table>
 <tr>
  <td style="width: 40%;">
   <label for="file">Image (optional):</label>
   <input type="file" name="file" value=""  />
  </td>
  <td style="width: 60%;">
   <input type="submit" name="submit" value="send" onclick="reload()" />
  </td>
 </tr>
</table>
</form>

and

public function post()
{
        move_uploaded_file($_FILES["file"]["tmp_name"], '/uploads'.$_FILES["file"]["name"]);

        $data = array(
                'userid' => $_POST['userid'],
                'thread' => $_POST['thread'],
                'text' => $_POST['text'],
                'image' => $_FILES["file"]["name"]
        );

        $this->db->insert('messages', $data);
}

In my database, everything works except image (a varchar) is always NULL.

Try removing:

onclick="reload()"

See if it works now. This may be breaking the file upload (it runs "reload" before the form is submitted).

If you want to reload the page instead of actually GOING to the posted page, you may want to look into POSTing through AJAX.