imageupload
This commit is contained in:
parent
de0b041520
commit
7d973eeed5
@ -64,6 +64,19 @@ class Accountheads extends CI_Controller
|
||||
case 'edit':
|
||||
$id = $this->uri->segment(4);
|
||||
if (isset($_POST['submit'])) {
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|jpeg|png';
|
||||
$config['max_size'] = 128 * 1024;
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ($this->upload->do_upload('account_image')) {
|
||||
$account_image_data = $this->upload->data();
|
||||
$account_image = $account_image_data['file_name'];
|
||||
}else{
|
||||
$current_account_image = $this->db->query("SELECT account_image FROM tbl_accounts WHERE account_id = '$id'")->row()->account_image;
|
||||
$account_image = $current_account_image;
|
||||
}
|
||||
// print_r($account_image);die;
|
||||
$TableData = array(
|
||||
'accategory_id' => filter_var($_POST['accategory_id']),
|
||||
//'account_code' => filter_var($_POST['account_code']),
|
||||
@ -78,6 +91,7 @@ class Accountheads extends CI_Controller
|
||||
'account_partyemail' => filter_var($_POST['account_partyemail']),
|
||||
'account_partycontactperson' => filter_var($_POST['account_partycontactperson']),
|
||||
'account_partycontactpersoncontact' => filter_var($_POST['account_partycontactpersoncontact']),
|
||||
'account_image' => $account_image,
|
||||
'created_on' => date('Y-m-d H:i:s'),
|
||||
'created_by' => 'admin',
|
||||
'remarks' => filter_var($_POST['remarks']),
|
||||
|
@ -60,7 +60,7 @@
|
||||
<div class="col-2">
|
||||
|
||||
<div class="text-center">
|
||||
<img class="profile-user-img img-fluid " src="../../dist/img/user4-128x128.jpg" alt="User profile picture">
|
||||
<img class="profile-user-img img-fluid " src="<?php echo isset($Account->account_image) && $Account->account_image ? base_url('uploads/' . $Account->account_image) : base_url('/dist/img/user4-128x128.jpg'); ?>" alt="User profile picture">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
@ -20,15 +20,15 @@
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputFile">Upload Image</label>
|
||||
<div class="input-group">
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" id="exampleInputFile">
|
||||
<label class="custom-file-label" for="exampleInputFile">Choose file</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<label for="exampleInputFile">Upload Image</label>
|
||||
<div class="input-group">
|
||||
<div class="custom-file">
|
||||
<input type="file" class="custom-file-input" id="exampleInputFile" name="account_image" value="<?php echo $TableData->account_image; ?>" onchange="previewImage(event)">
|
||||
<label class="custom-file-label" for="exampleInputFile">Choose file</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-7">
|
||||
@ -66,6 +66,14 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--image display-->
|
||||
|
||||
<div class="col-2">
|
||||
<img id="imagePreview" class="profile-user-img img-fluid " src="<?php echo isset($TableData->account_image) && $TableData->account_image ? base_url('uploads/' . $TableData->account_image) : base_url('/dist/img/user4-128x128.jpg'); ?>" alt="Account Image" >
|
||||
</div>
|
||||
<!--image display end-->
|
||||
|
||||
<!--COL END-->
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -154,4 +162,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function previewImage(event) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function() {
|
||||
var output = document.getElementById('imagePreview');
|
||||
output.src = reader.result;
|
||||
}
|
||||
reader.readAsDataURL(event.target.files[0]);
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user