edit form validation error - php

when i am performing validation on edit form it gives an error:
undefined variable score_id on line no-16, and then for all variable that is student_name, subject_name, marks.
my controller file.
public function edit($id)
{
$this->load->library('form_validation');
$score_id = $this->uri->segment('3');
$this->form_validation->set_rules('std_name','student_name','trim|required|alpha');
$this->form_validation->set_rules('txt_name','subject_name','trim|required|alpha');
$this->form_validation->set_rules('marks','marks','required|numeric');
if ($this->form_validation->run() == FALSE)
{
$score_id = $this->uri->segment('3');
$this->load->view('edit_score');
}
elseif($this->input->post('edit') && $this->input->post('edit_id')!='')
{
$score_id = $this->uri->segment('3');
$data = array(
'score_id' => $this->input->post('score_id'),
'student_name' => $this->input->post('std_name'),
'subject_name' => $this->input->post('txt_name'),
'marks' => $this->input->post('marks'),
);
$result = $this->score->update_record($id,$data);
header('location:'.base_url().'index.php/score_listing');
}
if($id)
{
echo "this is score_id".$id;
$result = $this->score->edit_score($id);
$data['action'] = 'edit';
$data['score_id'] = $result[0]->score_id;
$data['student_name'] = $result[0]->student_name;
$data['subject_name'] = $result[0]->subject_name;
$data['marks'] = $result[0]->marks;
}
echo "welome to edit page";
$this->load->view('edit_score',$data);
}
this is my edit file
<h1>Edit score</h1>
<?php $action = $score_id!='' ? 'edit/'.$score_id : 'add'; ?>
<form name="edit_score" method="post" action="<?php echo $action; ?>">
<input type="hidden" name="score_id" value="<?php echo $score_id;?>"/>
<?php echo form_hidden('admin_id',$this->load->session->userdata('admin_id')); ?>
<!--for above function use form helper in controller file -->
<table style="width:100%" border="0">
<tr>
<td>student Name:</td>
<td><input type="text" name="std_name" value="<?php echo $student_name; ?>"/></td>
<?php echo form_error("std_name"); ?>
</tr>
<tr>
<td>subject Name:</td>
<td><input type="text" name="txt_name" value="<?php echo $subject_name; ?>"/></td>
<?php echo form_error("txt_name"); ?>
</tr>
<tr>
<td>max marks:</td>
<td><input type="text" name="marks" value="<?php echo $marks; ?>" /></td>
<?php echo form_error("marks"); ?>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="edit" value="Submit"/></td>
</tr>
</table>
</form>
my uri is: http://localhost/ci/index.php/score_listing/edit/1
it gives following error:
Edit score
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: score_id
Filename: views/edit_score.php
Line Number: 16
Backtrace:
File: D:\xampp\htdocs\ci\application\views\edit_score.php
Line: 16
Function: _error_handler
File: D:\xampp\htdocs\ci\application\controllers\score_listing.php
Line: 64
Function: view
File: D:\xampp\htdocs\ci\index.php
Line: 292
Function: require_once

At first time load or when validation false it will run this code
if ($this->form_validation->run() == FALSE)
{
$score_id = $this->uri->segment('3');
$this->load->view('edit_score');
}
Here array argument not passed to view file like this $this->load->view('edit_score',$data);. So you have declare the null value or some other what you before the validation and should pass the array argument value
$data = array(
'score_id' => '',
'student_name' => '',
'subject_name' => '',
'marks' => '',
);
if ($this->form_validation->run() == FALSE)
{
$score_id = $this->uri->segment('3');
$this->load->view('edit_score',$data);// here is changes pass $data
}

Related

Fatal error: Uncaught Error: Cannot use object of type stdClass as array in C:\xampp\htdocs\MyShoppingList\list.php:487

When I run the code I get the error:
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in C:\xampp\htdocs\MyShoppingList\list.php:487 Stack trace: #0 {main} thrown in C:\xampp\htdocs\MyShoppingList\list.php on line 487;
I'm not sure why?
function updateList() {
//? Retrieve items from form POST, decode & unserialize using json. Empty array if not available.
$items = $_POST['items']
? json_decode(base64_decode($_POST ['items'], true))
: [];
//? Check if food and category was supplied.
if(filter_input(INPUT_POST, 'food') !== "" && filter_input(INPUT_POST, 'category') !== "") {
//? Add food/category as item to Shopping List
$items[] = [
"food" => filter_input(INPUT_POST, 'food'),
"category" => filter_input(INPUT_POST, 'category'),
];
}
return $items;
}
<input type="hidden" name="items" value="<?php echo base64_encode(json_encode($items)) ?>">
<div id="table">
<table width="100%">
<?php if ($items) { ?>
<?php foreach($items as $item){?>
<tr>
<td id="dairy">
<?php echo $item['category'];?>
</td>
</tr>
<form>
<tr>
<td id="data">
<?php echo'';?>
<label class="container">
<input
id="<?php echo "check${k}"; ?>"
type="checkbox"
name="<?php echo "check${k}"; ?>"
value="<?php echo $item['food']; ?>">
<span class="checkmark"></span>
</label>
</td>
</tr>
</form>
<?php } ?>
<?php } else { ?>
<tr>
<td align="center" style="padding: 20px">No items in list.</td>
</tr>
<?php } ?>
</table>
It’s a json_decode problem: It should have true as second parameter in order to get a result as array. In your code this function is used once, but without a second parameter.
This means: Instead of
json_decode(base64_decode($_POST ['items'], true))
It should be:
json_decode(base64_decode($_POST ['items']), true)
Or if the second parameter for base64_decode is needed:
json_decode(base64_decode($_POST ['items'], true), true)

how to upload image in codeigniter 3

i have trouble with uploading an image using codeigniter. i am new in this and didin't have a clue in how to upload image using codeigniter. so i hope any of you guys can help me out
this is my form named form_add.php
<form method="POST" action="<?php echo base_url()."index.php/crud/insert"; ? >">
<table style="width:110%" class="table table-striped table table-bordered table table-hover">
<td>Nama</td>
<td><input type="text" name="nama_produk"/></td>
</tr>
<tr>
<td>Info</td>
<td><input type="text" name="info_produk"/></td>
</tr>
<tr>
<td>Harga</td>
<td><input type="text" name="harga_produk"/></td>
</tr>
<tr>
<td>Stock</td>
<td><input type="text" name="stock"/></td>
</tr>
<?php echo form_open_multipart('upload/do_upload');?>
<tr>
<td>Gambar</td>
<td><input type="file" name="gambar_produk"></td>
</tr>
<tr>
<td>Di Buat Oleh</td>
<td><input type="text" name="penulis_produk"/></td>
</tr>
<tr>
<td>Kategori</td>
<td><input type="text" name="kategori"/></td>
</tr>
<tr>
<td>Kode Kategori</td>
<td><input type="text" name="kode_kategori"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsubmit" value="Simpan" /></td>
</tr>
</table>
</form>
and this is my controller named crud.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Crud extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index(){
$data = $this->mymodel->GetAll();
$this->load->view('view_all_produk',array('data' => $data));
}
public function add_data(){
$this->load->view('form_add');
}
public function insert(){
$nama_produk = $_POST['nama_produk'];
$info_produk = $_POST['info_produk'];
$harga_produk = $_POST['harga_produk'];
$stock = $_POST['stock'];
$penulis_produk = $_POST['penulis_produk'];
$gambar_produk = $_FILES['gambar_produk']['name'];
$gambar_tmp = $_FILES['gambar_produk']['tmp_name'];
$kategori = $_POST['kategori'];
$kode_kategori = $_POST['kode_kategori'];
$data_insert = array(
'nama_produk' => $nama_produk,
'info_produk' => $info_produk,
'harga_produk' => $harga_produk,
'stock' => $stock,
'penulis_produk' => $penulis_produk,
'gambar_produk' => $gambar_produk,
'kategori' => $kategori,
'kode_kategori' => $kode_kategori
);
$res = $this->mymodel->insertData('produk',$data_insert);
if($res >= 1){
$this->session->set_flashdata('pesan','Tambah Data Sukses');
redirect('crud/index');
}else{
echo "<h2>Insert Data Gagal!!!</h2>";
}
}
public function do_upload()
{
$config['upload_path'] = './assets/images';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 300;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('gambar_produk'))
{
$error = array('error' => $this->upload- >display_errors());
$this->load->view('form_add', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
}
}
and this is the model named mymodel.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mymodel extends CI_Model {
public function GetAll($where="") {
$data = $this->db->query('select * from produk '.$where);
return $data -> result_array();
}
public function insertData($tableName,$data){
$res = $this->db->insert($tableName,$data);
return $res;
}
public function updateData($tableName,$data,$where){
$res = $this->db->update($tableName,$data,$where);
return $res;
}
public function GetKategori($where=""){
$data = $this->db->query('select * from kategori '.$where);
return $data;
}
}
also this is what it shows after i run it
A PHP Error was encountered
Severity: Notice
Message: Undefined index: gambar_produk
Filename: controllers/crud.php
Line Number: 30
Backtrace:
File: C:\xampp\htdocs\genstore\admin\application\controllers\crud.php
Line: 30
Function: _error_handler
File: C:\xampp\htdocs\genstore\admin\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined index: gambar_produk
Filename: controllers/crud.php
Line Number: 31
Backtrace:
File: C:\xampp\htdocs\genstore\admin\application\controllers\crud.php
Line: 31
Function: _error_handler
File: C:\xampp\htdocs\genstore\admin\index.php
Line: 315
Function: require_once
A Database Error Occurred
Error Number: 1048
Column 'gambar_produk' cannot be null
INSERT INTO produk (nama_produk, info_produk, harga_produk, stock, penulis_produk, gambar_produk, kategori, kode_kategori) VALUES ('sada', 'asdas', 'asdasd', 'sdasd', 'sdasd', NULL, 'sadasd', '14')
Filename: C:/xampp/htdocs/genstore/admin/system/database/DB_driver.php
Line Number: 691
so can anyone tell me what's my mistake? thanks
Are you using multipart on the form?
<?php echo form_open_multipart('upload/do_upload');?>
https://www.codeigniter.com/userguide3/libraries/file_uploading.html
Edit: i see you are, there's a form within a form in your code!!
try this ! Send form-data encoded as "multipart/form-data":
<form method="POST" action="<?php echo base_url()."index.php/crud/insert"; ?>" enctype="multipart/form-data">
<table style="width:110%" class="table table-striped table table-bordered table table-hover">

Copy database contents from one table to another table in codeigniter

I need to copy table contents from table: user_openletter to table: country on clicking archive button. How to write a query to copy from,to,title,openletter,open_id from user_openletter to another table country. This a codeigniter app.
my controller code is :
public function store_user_data_archieve()
{
$match = $this->input->post('submit');
echo $match;
if($match == "Archieve")
{
$data = array(
'open_id' => $this->input->post('open_id'),
'featured' => '1',
'from' => $this->input->post('from'),
'to' => $this->input->post('to'),
'title' => $this->input->post('title'),
'archieve' => '1',
'latest' => '0',
'sponsor' => 'images/sponsor.png'
);
$this->load->database();
//load the model
$this->load->model('select');
//load the method of model
$data['r']=$this->select->store_user_data_archieve($data);
echo "success";
}
else if(!$match == "new")
{
$data = array(
'open_id' => $this->input->post('open_id'),
'featured' => '1',
'from' => $this->input->post('from'),
'to' => $this->input->post('to'),
'title' => $this->input->post('title'),
'openletter' => $this->input->post('openletter'),
'archieve' => '0',
'latest' => '1',
'sponsor' => 'images/sponsor.png'
);
$this->load->database();
//load the model
$this->load->model('select');
//load the method of model
$data['r']=$this->select->store_user_data_archieve($data);
echo "success";
}
else if(!$match == "Discard")
{
echo "failure";
}
}
My view code is:
<?php
foreach ($r->result() as $row)
{
?>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<td>from</td>
<td>to</td>
<td>title</td>
<td>openletter</td>
<td>Date & Time</td>
<td>open_id</td>
</tr>
<tr>
<form action="/index.php/welcome/store_user_data_archieve" method="post">
<td><input type="text" name="from" value="<?php echo $row->from;?>" /></td>
<td><input type="text" name="to" value="<?php echo $row->to;?>" /></td>
<td><input type="text" name="title" value="<?php echo $row->title;?>" /></td>
<td><input type="text" name="openletter" value="<?php echo $row->openletter;?>" /></td>
<td><input type="text" name="datetime" value="<?php echo $row->datetime;?>" /></td>
<td><input type="text" name="open_id" value="<?php echo $row->open_id;?>" /></td>
<td><div><input type="submit" name="submit" value="Archieve" /></div></td>
<td><div><input type="submit" name="new" value="new" /></div></td>
</form>
</tr>
</table>
<?php } ?>
My model code is:
public function store_user_data_archieve($data)
{
//data is retrieved from this query
$this->db->insert('country', $data);
$this->db->set('openletter');
$this->db->select('openletter');
$this->db->where('open_id', $data[open_id]);
$this->db->from('user_openletter');
// Produces: INSERT INTO mytable (title, name, date) VALUES ('{$title}', '{$name}', '{$date}')
}
As per our discussion you need to copy from,to,title,openletter,open_id from table user_openletter to country table
$this->db->select('from,to,title,openletter,open_id');// select your filed
$q = $this->db->get('user_openletter')->result(); // get result from table
foreach ($q as $r) { // loop over results
$this->db->insert('country', $r); // insert each row to country table
}
$this->db->select('from, to, title,openletter, open_id');
$result_set = $this->db->get('user_openletter')->result();
if(count($result_set) > 0) {
$this->db->insert_batch('country', $result_set);
}

input multiple value to one row in codeigniter

I have 3 pieces of the column, which I will inserting in one table in my database. The name of each form like this:
<h3><?= $title; ?></h3><?php echo form_open("admin/artikel/buat/");?>
<table width="95%">
<tr>
<td><b>Pilih Referensi Jurnal</b></td>
<td>
<input type="hidden" name="IDJurnal" id="IDJurnal" value="<?php echo $IDJurnal; ?>" />
<input type="text" name="volume" id="volume" value="<?php echo $volume; ?>" readonly="readonly" class="sedang" />
<?php echo anchor_popup('admin/artikel/popup', 'Referensi Jurnal', array('class' => 'button')); ?>
</td>
</tr>
<tr>
<td><b>Kategori</b></td>
<td>
<?php
echo form_dropdown('IDKategori', $kategori) . "";
?>
</td>
</tr>
<tr>
<td width="125"><strong>Judul</strong></td>
<td><input type="text" name="judul" class="panjang"></td>
</tr>
<tr>
<td width="125"><strong>Pengarang</strong></td>
<td>
<input type="text" name="pengarang" class="panjang">
<input type="text" name="pengarang" class="panjang">
<input type="text" name="pengarang" class="panjang">
</td>
</tr>
<tr>
<td><b>Abstract</b></td>
<td>
<?php
$data = array('name' => 'abstract');
echo $this->ckeditor->editor($data['name']);
?>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" class="button" value="Simpan">
<input type="button" class="button" value="Batal" onClick="javascript: history.go(-1)" />
</td>
</tr>
<?php
echo form_close();
?>
i want inserting the value from each form name to my sql table, like this:
CREATE TABLE `pengarang`(
`IDPengarang` INT(11)NOT NULL AUTO_INCREMENT,
`IDArtikel` INT(11)NOT NULL,
`nama_pengarang` VARCHAR(255)NOT NULL,
PRIMARY KEY(`IDPengarang`))ENGINE = INNODB DEFAULT CHARSET = utf8;
in my model like this:
function addArtikel() {
$now = date("Y-m-d H:i:s");
$data = array(
'IDJurnal' => $this->input->post('IDJurnal'),
'IDKategori' => $this->input->post('IDKategori'),
'judul' => $this->input->post('judul'),
'abstract' => $this->input->post('abstract'),
'created_time' => $now,
'created_by' => $_SESSION['username']
);
// $data1 = array(
// 'IDJurnal' => $this->input->post('IDJurnal'),
// 'IDKategori' => $this->input->post('IDKategori'),
// 'judul' => $this->input->post('judul'),
// 'abstract' => $this->input->post('abstract'),
// 'created_time' => $now,
// 'created_by' => $_SESSION['username']
// );
// $data2 = array(
// 'IDArtikel' => $this->input->post('IDArtikel'),
// 'nama_pengarang' => $this->input->post('pengarang')
// );
$this->db->insert('artikel', $data);
// $this->db->insert_batch('artikel', $data1);
// $this->db->insert_batch('pengarang', $data1);
}
in my controller
function buat() {
if ($this->input->post('judul')) {
$this->MArtikel->addArtikel();
$this->session->set_flashdata('message', 'Artikel telah di buat !');
redirect('admin/artikel/index', 'refresh');
} else {
// konfigurasi ckfinder dengan ckeditor
$this->load->library('ckeditor');
$this->load->library('ckfinder');
$this->ckeditor->basePath = base_url() . 'asset/ckeditor/';
$this->ckeditor->config['toolbar'] = 'Full';
$this->ckeditor->config['language'] = 'en';
$this->ckfinder->SetupCKEditor($this->ckeditor, '../../../asset/ckfinder/');
$data['title'] = "Tambah Artikel";
$data['main'] = 'admin/artikel/artikel_buat';
$data['jurnal'] = $this->MJurnal->getJurnalDropDown();
$data['kategori'] = $this->MKategori->getKategoriDropDown();
$this->load->vars($data);
$this->load->view('dashboard/template');
}
}
What should I add to my controller and my model, that would make the results in my table looks like this
IDPengarang IDArtikel nama_pengarang
1 1 testing 1
2 1 testing 2
3 1 testing 3
thank's before

Code Igniter CRUD app: thumbnail image doesn't upload. Receive database error because NULL

Making a form that will accept a bunch of textual data and an image upload.
Keep getting this error when adding new item to both tables:
Error Number: 1048
Column 'id_path' cannot be null
INSERT INTO thumbnails (id_path, id_data_row) VALUES (NULL, 17)
Filename: C:\wamp\www\project\system\database\DB_driver.php
Line Number: 330
What I'm trying to do is add text data(stuff like title, text, price, etc.) into one table(data) and then upload an image and add its full upload path(as primary key in thumbnails table) and the id of the inserted text data row(to link it with the thumbnail in thumbnails table) into thumbnails table.
For some reason it keeps passing NULL as the full upload path to thumbnails table.
crud.php(the controller):
function add()
{
//Set validation properties
$this->_set_fields();
//Set common properties
$data['title'] = 'Add new data row';
$data['message'] = '';
$data['action'] = site_url('crud/addDataRow');
$data['link_back'] = anchor('crud/index', 'Back to list', array('class' => 'back'));
//Load the view
$this->load->view('templates/header', $data);
$this->load->view('pages/crud_edit', $data);
$this->load->view('templates/footer');
}
function addDataRow()
{
//Set common properties
$data['title'] = 'Add new data row';
$data['action'] = site_url('crud/addDataRow');
$data['link_back'] = anchor('crud/index/', 'Back to list', array('class' => 'back'));
//Set validation properties
$this->_set_fields();
$this->_set_rules();
//Run validation
if($this->form_validation->run() == FALSE)
{
$data['message'] = '';
}
else
{
//Save the data
$full_file_path = null;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$path_to_uploads='./uploads';
$config['upload_path'] = $path_to_uploads;
$this->load->library('upload', $config);
//add this
$this->upload->initialize($config);
if (!$this->upload->do_upload()){
$error = $this->upload->display_errors();
echo "<script>alert($error);</script>";
}else{
$upload_data=$this->upload->data();
$file_name=$upload_data['file_name'];
$full_file_path = $path_to_uploads.'/'.$file_name;
}
$data_row = array(
'title' => $this->input->post('title'),
'text' => $this->input->post('text'),
'price' => $this->input->post('price'),
'status' => $this->input->post('status'),
'type' => $this->input->post('type')
);
$id = $this->crud_model->save($data_row);
$thumbnail_row = array(
'id_path' => $full_file_path,
'id_data_row' => $id
);
$this->crud_model->save_thumbnail($thumbnail_row);
//Set form input name="id"
$this->form_validation->id = $id;
//Set user message
$data['message'] = '<div class="success">New data row added!</div>';
}
$this->load->view('templates/header', $data);
$this->load->view('pages/crud_edit', $data);
$this->load->view('templates/footer');
}
crud_model.php(the model):
//Add new data row
function save($data)
{
$this->db->insert($this->tbl_data, $data);
return $this->db->insert_id();
}
//Add the thumbnail upload path and id of the row in data table to link them
function save_thumbnail($data)
{
$this->db->insert($this->tbl_thumbnails, $data);
return $this->db->insert_id();
}
EDIT(html form code):
crud_edit.php(html form code for adding a new item or updating an existing one):
<div id="contentColumn">
<h1><?php echo $title; ?></h1>
<?php echo $message; ?>
<form method="post" action="<?php echo $action; ?>" multipart="multipart">
<div class="data">
<table>
<tr>
<td width="30%">ID</td>
<td>
<input type="text" name="id" disabled="disabled" class="text" value="<?php echo set_value('id'); ?>"/>
<input type="hidden" name="id" value="<?php echo set_value('id',$this->form_data->id); ?>"/>
</td>
</tr>
<tr>
<td valign="top">Title<span style="color:red;">*</span></td>
<td>
<input type="text" name="title" class="text" value="<?php echo set_value('title',$this->form_data->title); ?>"/>
<?php echo form_error('title'); ?>
</td>
</tr>
<tr>
<td valign="top">Text<span style="color:red;">*</span></td>
<td>
<textarea name="text" class="text">
<?php echo set_value('text',$this->form_data->text); ?>
</textarea>
<?php echo form_error('text'); ?>
</td>
</tr>
<tr>
<td valign="top">Price<span style="color:red;">*</span></td>
<td>
<input type="text" name="price" class="text" value="<?php echo set_value('price',$this->form_data->price); ?>"/>
<?php echo form_error('price'); ?>
</td>
</tr>
<tr>
<td valign="top">Thumbnail<span style="color:red;">*</span></td>
<td>
<?php echo form_upload(array('name'=>'thumb', 'type'=>'file', 'accept'=>'image/*'))?>
<!--<input type="file" name="thumb" size="20" />-->
<?php echo form_error('thumb'); ?>
</td>
</tr>
<!--
<tr>
<td valign="top">Images<span style="color:red;">*</span></td>
<td>
<input type="text" name="images" class="text" value="<?php echo set_value('images',$this->form_data->images); ?>"/>
<?php echo form_upload(array('name'=>'images', 'type'=>'file', 'multiple'=>'multiple', 'accept'=>'image/*'))?>
<?php echo form_error('images'); ?>
</td>
</tr>
-->
<tr>
<td valign="top">Status</td>
<td>
<input type="text" name="status" class="text" value="<?php echo set_value('status',$this->form_data->status); ?>"/>
<?php echo form_error('status'); ?>
</td>
</tr>
<tr>
<td valign="top">Type<span style="color:red;">*</span></td>
<td>
<input type="text" name="type" class="text" value="<?php echo set_value('type',$this->form_data->type); ?>"/>
<?php echo form_error('type'); ?>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save" /></td>
</tr>
</table>
</div>
</form>
<br />
<?php echo $link_back; ?>
</div>
Change php code as below
$image1=$this->input->post('thumb');
if (!$this->upload->do_upload($image1)){
if (!$this->upload->do_upload()){
$error = $this->upload->display_errors();
echo "<script>alert($error);</script>";
}else{
$upload_data=$this->upload->data();
$file_name=$upload_data['file_name'];
$full_file_path = $path_to_uploads.'/'.$file_name;
$thumbnail_row = array(
'id_path' => $full_file_path,
'id_data_row' => $id
);
$this->crud_model->save_thumbnail($thumbnail_row);
}
My guess is the upload is failing, since you're trying to do the save regardless of the upload failing the value for full_file_path is going to be empty. By the way save ONLY the file name and put the path in your display code. Saving the path makes it a huge headache to move those files to another location

Categories