我已经在'function()'中成功完成'echo',结果就出来了......
问题是,当我尝试将其放入数据库中的表时,只有Photos成功,但其他数据不会进入表中
Controller Home.php中的
public function insert_data()
{
$config['upload_path'] = 'users/images/';
$config['allowed_types'] = 'gif|jpg|png';
$config['overwrite'] = TRUE;
$data_img_post = array();
if ( isset($_FILES['images-post']) ) {
$IMAGE = $_FILES['images-post'];
$COUNT_IMAGE = count($IMAGE['name']);
for ($i=0; $i < $COUNT_IMAGE; $i++) {
$_FILES['images-post']['name'] = $IMAGE['name'][$i];
$_FILES['images-post']['type'] = $IMAGE['type'][$i];
$_FILES['images-post']['tmp_name'] = $IMAGE['tmp_name'][$i];
$_FILES['images-post']['error'] = $IMAGE['error'][$i];
$_FILES['images-post']['size'] = $IMAGE['size'][$i];
$this->upload->initialize($config);
$this->upload->do_upload('images-post');
$data_img_post[] = $this->upload->data();
}
}
$data_post = array(
'dbi_post_user_name' => $info->dbi_user_name,
'dbi_post_username' => $info->dbi_username,
'dbi_post_user_gender' => $info->dbi_user_gender,
'dbi_post_content' => $this->input->post('content-post'),
'dbi_post_tags' => $this->input->post('tags'),
'dbi_post_select_privacy' => $this->input->post('privacy-select'),
'dbi_post_dir_image' => $this->get_file_name($data_img_post)
);
$this->users_model->insert_data_post($data_post);
}
private function get_file_name($data_img_post){
$COUNT_DATA_IMG = count($data_img_post);
for ($i=0; $i < $COUNT_DATA_IMG; $i++) {
echo $data_img_post[$i]['file_name'].' ';
}
}
Ajax XHR.js中的
$('#form-create-post').submit(function(ev){
ev.preventDefault();
$.ajax({
url : "home",
type : "post",
data : new FormData(this),
cache : false,
contentType : false,
processData : false,
success : function(data) {
console.log(data);
}
});
});
请纠正我的错误:D
答案 0 :(得分:2)
删除soup
并尝试此操作
private function() get_file_name()