나는 inilabs 학교 관리 스크립트를 잘 사용하고 있습니다. 하지만 나는 수정하려고 노력하고있어. 나는 데이터베이스 여기Codeigniter : codeigniter를 사용하여 두 개 이상의 이미지를 업로드하는 방법
하나 개 이상의 이미지를 업로드 할은 add.php
' <?php
if(isset($image))
echo "<div class='form-group has-error' >";
else
echo "<div class='form-group' >";
?>
<label for="photo" class="col-sm-2 control-label col-xs-8 col-md-2">
<?=$this->lang->line("student_photo")?>
</label>
<div class="col-sm-4 col-xs-6 col-md-4">
<input class="form-control" id="uploadFile1" placeholder="Choose File" disabled />
</div>
<div class="col-sm-2 col-xs-6 col-md-2">
<div class="fileUpload btn btn-success form-control">
<span class="fa fa-repeat"></span>
<span><?=$this->lang->line("upload")?></span>
<input id="uploadBtn1" type="file" class="upload" name="image" />
</div>
</div>
<span class="col-sm-4 control-label col-xs-6 col-md-4">
<?php if(isset($image)) echo $image; ?>
</span>
</div>
<?php
if(isset($imageaadhar))
echo "<div class='form-group has-error' >";
else
echo "<div class='form-group' >";
?>
<label for="aadhar" class="col-sm-2 control-label col-xs-8 col-md-2">
<?=$this->lang->line("student_aadhar")?>
</label>
<div class="col-sm-4 col-xs-6 col-md-4">
<input class="form-control" id="uploadFile2" placeholder="Choose File" disabled />
</div>
<div class="col-sm-2 col-xs-6 col-md-2">
<div class="fileUpload btn btn-success form-control">
<span class="fa fa-repeat"></span>
<span><?=$this->lang->line("upload")?></span>
<input id="uploadBtn2" type="file" class="upload" name="imageaadhar" />
</div>
</div>
<span class="col-sm-4 control-label col-xs-6 col-md-4">
<?php if(isset($imageaadhar)) echo $imageaadhar; ?>
</span>
</div>
<?php
if(isset($imagebirthc))
echo "<div class='form-group has-error' >";
else
echo "<div class='form-group' >";
?>
<label for="birthc" class="col-sm-2 control-label col-xs-8 col-md-2">
<?=$this->lang->line("student_birthc")?>
</label>
<div class="col-sm-4 col-xs-6 col-md-4">
<input class="form-control" id="uploadFile3" placeholder="Choose File" disabled />
</div>
<div class="col-sm-2 col-xs-6 col-md-2">
<div class="fileUpload btn btn-success form-control">
<span class="fa fa-repeat"></span>
<span><?=$this->lang->line("upload")?></span>
<input id="uploadBtn3" type="file" class="upload" name="image" />
</div>
</div>
<span class="col-sm-4 control-label col-xs-6 col-md-4">
<?php if(isset($imagebirthc)) echo $imagebirthc; ?>
</span>
</div>'
업로드 한 이미지 이것은 컨트롤러 /은 add.php입니다. 두 개의 이미지를 추가로 업로드하는 방법은 무엇입니까?
$classesID = $this->input->post("classesID");
if($classesID != 0) {
$this->data['sections'] = $this->section_m->get_order_by_section(array("classesID" =>$classesID));
} else {
$this->data['sections'] = "empty";
}
$this->data['sectionID'] = $this->input->post("sectionID");
if($_POST) {
$rules = $this->rules();
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == FALSE) {
$this->data["subview"] = "student/add";
$this->load->view('_layout_main', $this->data);
} else {
$sectionID = $this->input->post("sectionID");
if($sectionID == 0) {
$this->data['sectionID'] = 0;
} else {
$this->data['sections'] = $this->section_m->get_allsection($classesID);
$this->data['sectionID'] = $this->input->post("sectionID");
}
$dbmaxyear = $this->student_m->get_order_by_student_single_max_year($classesID);
$maxyear = "";
if(count($dbmaxyear)) {
$maxyear = $dbmaxyear->year;
} else {
$maxyear = date("Y");
}
$section = $this->section_m->get_section($sectionID);
$array = array();
$array["name"] = $this->input->post("name");
$array["dob"] = date("Y-m-d", strtotime($this->input->post("dob")));
$array["sex"] = $this->input->post("sex");
$array["religion"] = $this->input->post("religion");
$array["email"] = $this->input->post("email");
$array["phone"] = $this->input->post("phone");
$array["address"] = $this->input->post("address");
$array["classesID"] = $this->input->post("classesID");
$array["sectionID"] = $this->input->post("sectionID");
$array["section"] = $section->section;
$array["roll"] = $this->input->post("roll");
$array["username"] = $this->input->post("username");
$array['password'] = $this->student_m->hash($this->input->post("password"));
$array['usertype'] = "Student";
$array['parentID'] = $this->input->post('guargianID');
$array['library'] = 0;
$array['hostel'] = 0;
$array['transport'] = 0;
$array['create_date'] = date("Y-m-d");
$array['year'] = $maxyear;
$array['totalamount'] = 0;
$array['paidamount'] = 0;
$array["create_date"] = date("Y-m-d h:i:s");
$array["modify_date"] = date("Y-m-d h:i:s");
$array["create_userID"] = $this->session->userdata('loginuserID');
$array["create_username"] = $this->session->userdata('username');
$array["create_usertype"] = $this->session->userdata('usertype');
$array["studentactive"] = 1;
$new_file = "";
if($_FILES["image"]['name'] !="") {
$file_name = $_FILES["image"]['name'];
$file_name_rename = $this->insert_with_image($this->input->post("username"));
$explode = explode('.', $file_name);
if(count($explode) >= 2) {
$new_file = $file_name_rename.'.'.$explode[1];
$config['upload_path'] = "./uploads/images";
$config['allowed_types'] = "gif|jpg|png";
$config['file_name'] = $new_file;
$config['max_size'] = '1024';
$config['max_width'] = '3000';
$config['max_height'] = '3000';
$array['photo'] = $new_file;
$this->load->library('upload', $config);
if(!$this->upload->do_upload("image")) {
$this->data["image"] = $this->upload->display_errors();
$this->data["subview"] = "student/add";
$this->load->view('_layout_main', $this->data);
} else {
$data = array("upload_data" => $this->upload->data());
$this->student_m->insert_student($array);
$this->session->set_flashdata('success', $this->lang->line('menu_success'));
redirect(base_url("student/index"));
}
} else {
$this->data["image"] = "Invalid file";
$this->data["subview"] = "student/add";
$this->load->view('_layout_main', $this->data);
}
} else {
$array["photo"] = $new_file;
$this->student_m->insert_student($array);
$this->session->set_flashdata('success', $this->lang->line('menu_success'));
redirect(base_url("student/index"));
}
}
} else {
$this->data["subview"] = "student/add";
$this->load->view('_layout_main', $this->data);
}
} else {
$this->data["subview"] = "error";
$this->load->view('_layout_main', $this->data);
}
}
날
을 업로드하시기 바랍니다 도움말, 난 당신이 $ this-> 입력 -> 포스트()를 사용하는 것이 좋습니다; 게시 된 모든 데이터에 대해 게시 된 모든 데이터의 배열을 가져오고 특정 값이있는 특정 키를 추가 할 수 있습니다. –
[코드 서명자를 사용하여 여러 이미지 업로드] (0120-998-304). –
이 코드는 정상적으로 작동합니다. 학생의 사진을 업로드 할 수 있습니다. 하지만 업로드 카드, 출생 증명서 등 업로드 버튼을 추가했습니다.하지만 컨트롤러를 코딩하는 방법을 모르겠습니다. – user7492700