gpt4 book ai didi

php - 代码点火器 : how to upload more than one image with codeigniter

转载 作者:行者123 更新时间:2023-11-30 22:05:21 25 4
gpt4 key购买 nike

<分区>

我有 inilabs 学校管理脚本,工作正常。但我正在尝试修改。我想在数据库中上传多张图片

这里是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>'

这是上传单张图片的controller/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);
}
}

请帮帮我

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com