“您没有选择要上传的文件”;上传编码器时显示消息


"you did not select a file to upload" messgae is showing while uploading codeigniter

我正在尝试上传图像到我的资产文件夹。我做不好。我想保存图像的名称为"最后插入id"

   $.ajax({
                url: base_url+"register/reg_submit/",
                data: $('#career_submit_form').serialize(),//returns all cells' data
                dataType: 'json',
                type: 'POST',
                success: function (res) {
                    alert(res.result)
   },
reg_submit
      $application_insert = $this->career->insert_student_application($personal_details,$parent_details,$other_details);
    $config['upload_path'] = './application/assets/images/user_image/';
    $config['allowed_types'] = 'jpg'; 
    $config['file_name'] = $application_insert.'.jpg'; 
    $this->load->library('upload', $config); 
    if (!$this->upload->do_upload('userfile'))
    {     
        echo $this->upload->display_errors();  
    } 

你可以使用'Jquery Form'插件来使用Ajax提交文件。链接

示例代码:

<form id="myForm" action="comment.php" method="post" enctype='multipart/form-data' accept-charset='utf-8'> 
    Name: <input type="text" name="name" /> 
    File: <input type="file" name="document" /> 
    <input type="submit" value="Submit Comment" /> 
</form>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
    <script src="http://malsup.github.com/jquery.form.js"></script> 
    <script> 
        // wait for the DOM to be loaded 
        $(document).ready(function() { 
            // bind 'myForm' and provide a simple callback function 
            $('#myForm').ajaxForm(function() { 
                alert("Thank you for your comment!"); 
            }); 
        }); 
    </script>