Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Jquery,codeigniter 2.1文件上传问题_Php_Javascript_Jquery_Codeigniter - Fatal编程技术网

Php Jquery,codeigniter 2.1文件上传问题

Php Jquery,codeigniter 2.1文件上传问题,php,javascript,jquery,codeigniter,Php,Javascript,Jquery,Codeigniter,我有如下jquery代码: $(parent).on('click', '.izmeni', function() { var clone = $(this).parent().clone(); var name = $(this).siblings('.name').text(); var surname = $(this).siblings('.surname').text(); var info = $(this).sib

我有如下jquery代码:

$(parent).on('click', '.izmeni', function() {

        var clone = $(this).parent().clone();

        var name = $(this).siblings('.name').text();
        var surname = $(this).siblings('.surname').text();
        var info = $(this).siblings('.info').text();
        var email = $(this).siblings('.email').text();   
        var phone = $(this).siblings('.phone').text();   
        var date_birth = $(this).siblings('.date_birth').text();   
        var id_lok = $(this).siblings('.lokacija').val();    
        var id = $(this).siblings('.id').val();             

        <?php $attributes = array('class' => 'update_form'); ?>

        $(this).hide();
        $(this).siblings('.permission').hide();
        $(this).siblings('strong').hide();
        $(this).parent().wrapInner('<?php echo form_open_multipart('upload/do_upload', $attributes);?></form>');
        $(this).parent().prepend('<input type="file" name="userfile" size="20" />');
        $(this).parent().append('<div class="lokacija"></div>');
        $(this).parent().append('<select name="pol"><option value="m">Muški</option><option value="f">Ženski</option></select>');        
        $(this).parent().append('<input type="submit" value="Submit" />');
        $(this).parent().append('<a id="otkazi">Otkazi</a>');

        $(this).siblings('.name').replaceWith('<input name="name" value="' + name + '" />');
        $(this).siblings('.surname').replaceWith('<input name="surname" value="' + surname + '" />');
        $(this).siblings('.info').replaceWith('<textarea name="info">' + info + '</textarea>');       
        $(this).siblings('.email').replaceWith('<input name="email" value="' + email + '" />');
        $(this).siblings('.phone').replaceWith('<input name="phone" value="' + phone + '" />');          
        $(this).siblings('.date_birth').load("<?php echo base_url() ?>form/date_birth", {'date' : date_birth});   
        $(this).siblings('.lokacija').load("<?php echo base_url() ?>form/location", {'id' : id_lok});   

        $(this).siblings('#otkazi').click(function(){
            $(this).parents("div:first").replaceWith(clone);
            $(this).show();
        });

        $(".update_form").submit(function(){
            data = $(this).serialize();
            console.log(data);
            forma = $(this);
            $.ajax({
                type : "POST",
                data : data,
                url : "<?php echo base_url() ?>/user/update_person",
                success : function(){
                    forma.slideUp('slow');
                    $("#all_users").fadeOut('slow', function(){
                        $(this).empty().load("<?php echo base_url() . "ajax/get_all_users" ?>", function(){
                            $(this).hide().slideDown('slow');
                        })
                    });
                }
            })
            return false;
        });
    });
Jquery正在替换页面上的元素,并创建表单,用户可以在其中更新数据。(这工作正常,更新时图像部分不工作)。当我尝试更新图像时,出现以下错误:

您没有选择要上载的文件

我也有创建新用户的表单,它使用

功能人员\u img\u上传()


它工作正常(表单不是通过jquery创建的)。有什么问题吗

文件不是通过ajax请求上传的。你需要提交整个表单,或者如果你想通过ajax提交表单,那么你可以通过iframe发布表单。

这超出了我目前的知识水平:D.现在需要上传简单的PHP文件。
function update_person(){

           if($this->person_img_upload() != false){$data['picture'] = $this->person_img_upload();}else{echo "131231";}

               $data = array(
            'name' => $_POST['name'],
            'surname' => $_POST['surname'],
            'telephone' => $_POST['phone'],
            'info' => $_POST['info'],            
            'location' => $_POST['location'],
            'gender' => $_POST['pol'],
            'date_birth' => $this->date()
               );
            $id = $_POST['id'];
            echo $id;
            $this->db->where('id_person', $id);
            $this->db->update('person', $data);
            $this->update_user($id);
           }


function person_img_upload(){
               $config = array (
            'allowed_types' => 'jpg|jpeg|png|gif',
            'upload_path' => $this->path
        );
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $q = $this->upload->data();
        if ( !$this->upload->do_upload()){
            $error = array('error' => $this->upload->display_errors());
            $this->load->view('upload_form', $error);
            return false;}
        else{
            $this->upload->do_upload(); 
            $q = $this->upload->data();        
            return $q['file_name'];
                }     
           }