Php Codeigniter jQuery文件上载不工作
PHP代码: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>"; $
$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) {
}
});
});