[eluser]cestaz18[/eluser]
HELP please...
i got also the same problem in this thread...
i read and follow all your discussion here but it had'nt work in my form..
please help me..
here's my code
VIEW
Code:
<div class="infield">
<?php echo form_open_multipart('at_reports/post');?>
<input type="file" name="userfile" class="tb" title="<?=lang('icon');?>"/>
<input type="submit" value="upload" />
</form>
<!--<input type="text" name="icon" class="tb" title="<?=lang ('icon');?>" />-->
</div>
CONTROLLER
IN MY FUNCTION POST..HERE'S MY FILE UPLOADING CODE
Code:
function post() {
//$this->output->enable_profiler(true);
$c = "";
$data['action'] = $this->input->post('action');
.....
else if ($data['action']=='save') {
$item = $this->input->post("item");
$dt['module_name'] = $this->input->post('module_name');
$report_exist = $this->Reports->getDetailsByName($dt);
if ($report_exist && $item != $report_exist['module_id'])
{
$c .= 'Report already exists.';
$data['action'] = 'exist';
}
else
{
$config['upload_path'] = './reports/module/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$this->upload->do_upload();
$file_data = $this->upload->data();
$file_name = $file_data['file_name'];
$fields = array(
"module_name"=>$this->input->post('module_name'),
"slug"=>$this->input->post('slug'),
"icon"=>$file_data['file_name'],
"report_file_name"=>$this->input->post('report_file_name'),
"sql_select"=>$this->input->post('sql_select'),
"sql_filter"=>$this->input->post('sql_filter'),
"sql_order"=>$this->input->post('sql_order')
);
/*foreach ($fields as $field)
{
if (isset($_POST[$field])) $dt[$field] = $this->input->post($field);
}*/
$item = $this->input->post("item");
$rows = $this->input->post("row0");
$data['item'] = $this->Reports->save($fields,$item,$rows);
$c .= 'Successfully saved item';
}
$data['response'] = $c;
$json['json'] = $data;
}
MODEL
Code:
function save($data,$item,$details) {
if ($item == '') {
$data['link'] = "reports/view";
$this->db->trans_start();
$this->db->insert('sec_reports', $data);
$item = $this->db->insert_id();
$this->save_detail($item,$details);
$this->db->trans_complete();
}
else {
$this->db->trans_start();
$this->db->where('module_id', $item);
$this->db->update('sec_reports', $data);
$this->save_detail($item,$details);
$this->db->trans_complete();
}
return $item;
}
i got only other fields to be save in database..only the icon field does'nt save in database...the value always saved is empty or null...
please help me to find the problem in my code..
tnx in advance..