Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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 Codeigniter jQuery文件上载不工作_Php_Jquery_Codeigniter - Fatal编程技术网

Php Codeigniter jQuery文件上载不工作

Php Codeigniter jQuery文件上载不工作,php,jquery,codeigniter,Php,Jquery,Codeigniter,PHP代码: $files = json_decode($this->input->post('Image')); echo "<pre>"; print_r($files); echo "</pre>"; 控制台消息: $files = json_decode($this->input->post('Image')); echo "<pre>"; print_r($files); echo "</pre>"; $

PHP代码:

$files = json_decode($this->input->post('Image'));
echo "<pre>";
print_r($files);
echo "</pre>";
控制台消息:

$files = json_decode($this->input->post('Image'));
echo "<pre>";
print_r($files);
echo "</pre>";
   $(document).ready(function (e) {
                    var file_name = $('#id_file_input').prop('files')[0];
                    var form_data = new FormData();
                    form_data.append('img_file', file_data);
                    $('#vid_file').prop('disabled', true);
                    $.ajax({
                    url: '<?php echo base_url(); ?>Controller/function_name', 
                        dataType: 'text', 
                        cache: false,
                        contentType: false,
                        processData: false,
                        data: form_data,
                        type: 'post',
                          success: function (response) {

                        }
                    });
                    });

我正在尝试将图像文件上载到Codeigniter控制器。但当我打印$file的值时。然后显示空数组。

尝试此代码,并使用简单的$\u文件['img\u file']['file\u name']在控制器中获取文件

$files = json_decode($this->input->post('Image'));
echo "<pre>";
print_r($files);
echo "</pre>";
$(文档).ready(函数(e){
var file_name=$('#id_file_input').prop('files')[0];
var form_data=new FormData();
表单数据。追加('img文件',文件数据);
$('vid_file').prop('disabled',true);
$.ajax({
url:“控制器/函数名称”,
数据类型:“文本”,
cache:false,
contentType:false,
processData:false,
数据:表格数据,
键入:“post”,
成功:功能(响应){
}
});
});

man一切都是动态的,不是静态的。人们可以为图像添加新字段。您的代码在控制器中的什么位置/
["C:\\fakepath\\abhishek.jpg","C:\\fakepath\\krunal.jpg","C:\\fakepath\\nitin.jpg"]
   $(document).ready(function (e) {
                    var file_name = $('#id_file_input').prop('files')[0];
                    var form_data = new FormData();
                    form_data.append('img_file', file_data);
                    $('#vid_file').prop('disabled', true);
                    $.ajax({
                    url: '<?php echo base_url(); ?>Controller/function_name', 
                        dataType: 'text', 
                        cache: false,
                        contentType: false,
                        processData: false,
                        data: form_data,
                        type: 'post',
                          success: function (response) {

                        }
                    });
                    });