From 7d973eeed523c4447c027f20d3031450b34b4fa9 Mon Sep 17 00:00:00 2001 From: Sampanna Rimal Date: Tue, 16 Jul 2024 17:52:18 +0545 Subject: [PATCH] imageupload --- .../controllers/accounts/Accountheads.php | 14 +++++++ .../views/accounts/accountheads/details.php | 2 +- .../views/accounts/accountheads/edit.php | 39 ++++++++++++++----- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/account/application/controllers/accounts/Accountheads.php b/account/application/controllers/accounts/Accountheads.php index a553941..8dfb86d 100644 --- a/account/application/controllers/accounts/Accountheads.php +++ b/account/application/controllers/accounts/Accountheads.php @@ -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']), diff --git a/account/application/views/accounts/accountheads/details.php b/account/application/views/accounts/accountheads/details.php index cec1a7f..a3d8b31 100644 --- a/account/application/views/accounts/accountheads/details.php +++ b/account/application/views/accounts/accountheads/details.php @@ -60,7 +60,7 @@
- User profile picture + User profile picture
diff --git a/account/application/views/accounts/accountheads/edit.php b/account/application/views/accounts/accountheads/edit.php index 89207ba..9b8c226 100644 --- a/account/application/views/accounts/accountheads/edit.php +++ b/account/application/views/accounts/accountheads/edit.php @@ -20,15 +20,15 @@
- -
-
- - -
- -
-
+ +
+
+ + +
+
+
+
@@ -66,6 +66,14 @@
+ + + +
+ Account Image +
+ +
@@ -154,4 +162,15 @@
- \ No newline at end of file + + + \ No newline at end of file