Welcome Guest, Not a member yet? Register   Sign In
Form Data and File Upload
#20

[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">
                                    &lt;?php echo form_open_multipart('at_reports/post');?&gt;
                                    &lt;input type="file" name="userfile" class="tb" title="&lt;?=lang('icon');?&gt;"/&gt;
                                    &lt;input type="submit" value="upload" /&gt;
                                    &lt;/form&gt;
                                    &lt;!--&lt;input type="text" name="icon" class="tb" title="&lt;?=lang ('icon');?&gt;" /&gt;--&gt;
                                </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..


Messages In This Thread
Form Data and File Upload - by El Forum - 11-30-2009, 03:48 PM
Form Data and File Upload - by El Forum - 11-30-2009, 06:28 PM
Form Data and File Upload - by El Forum - 11-30-2009, 08:57 PM
Form Data and File Upload - by El Forum - 11-30-2009, 08:58 PM
Form Data and File Upload - by El Forum - 12-01-2009, 01:21 AM
Form Data and File Upload - by El Forum - 12-01-2009, 02:39 AM
Form Data and File Upload - by El Forum - 12-01-2009, 07:34 AM
Form Data and File Upload - by El Forum - 12-01-2009, 07:39 AM
Form Data and File Upload - by El Forum - 12-01-2009, 07:41 AM
Form Data and File Upload - by El Forum - 12-01-2009, 07:43 AM
Form Data and File Upload - by El Forum - 12-01-2009, 07:55 AM
Form Data and File Upload - by El Forum - 12-01-2009, 08:17 AM
Form Data and File Upload - by El Forum - 12-01-2009, 08:22 AM
Form Data and File Upload - by El Forum - 12-01-2009, 08:59 AM
Form Data and File Upload - by El Forum - 12-01-2009, 09:20 AM
Form Data and File Upload - by El Forum - 12-01-2009, 10:57 AM
Form Data and File Upload - by El Forum - 12-01-2009, 11:03 AM
Form Data and File Upload - by El Forum - 12-01-2009, 05:43 PM
Form Data and File Upload - by El Forum - 12-02-2009, 05:15 AM
Form Data and File Upload - by El Forum - 01-21-2010, 12:51 AM
Form Data and File Upload - by El Forum - 01-21-2010, 08:29 AM
Form Data and File Upload - by El Forum - 01-21-2010, 08:15 PM
Form Data and File Upload - by El Forum - 12-07-2010, 06:13 AM
Form Data and File Upload - by El Forum - 12-07-2010, 12:08 PM
Form Data and File Upload - by El Forum - 12-07-2010, 07:55 PM
Form Data and File Upload - by El Forum - 12-08-2010, 11:14 AM
Form Data and File Upload - by El Forum - 10-05-2012, 02:38 AM
Form Data and File Upload - by El Forum - 10-05-2012, 02:54 AM
Form Data and File Upload - by El Forum - 10-07-2012, 06:02 PM
Form Data and File Upload - by El Forum - 10-07-2012, 06:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB