Welcome Guest, Not a member yet? Register   Sign In
Upload problem,newbie here please help :)
#1

[eluser]Unknown[/eluser]
how to insert upload form in my function?
controller file
Code:
class Hasil_rad extends Controller
{
function Hasil_rad()
    {
        parent::Controller();
              $this->load->helper(array('form', 'url'));
        if ($this->session->userdata('logged_in')==FALSE)
            redirect('main');
    }

function konfirmasi_tambah_hasil_rad($pasien_id, $r_id)
    {
        if($this->input->post('tambah'))
        {
                $this->load->model('hasil_pemeriksaan_rad_model');
                $data = array(
                    'pasien_id' => $pasien_id,
                    'hasil_rad_id' => $r_id,
                        'tanggal' => $_POST['tanggal'],
                        'jenis_rad_id' => $_POST['j_id'],
                        'hasil_rad_1' => $_POST['hasil_1'],
                        'hasil_rad_2' => $_POST['hasil_2'],
                        'hasil_rad_3' => $_POST['hasil_3'],
                        'hasil_rad_4' => $_POST['hasil_4'],
                        'hasil_rad_5' => $_POST['hasil_5'],
                    'hasil_analisis_rad' => $_POST['keterangan']
                    
                );
                $this->db->insert('hasil_rad', $data);
                redirect('hasil_pemeriksaan/index/'.$pasien_id);
            }
        
        
        else
        {
            redirect('hasil_pemeriksaan/index/'.$pasien_id);
        }
    }
}

function do_upload($file)
    {
        
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        $this->upload->initialize($config);
        $this->load->library('upload', $config);
        
        if ( ! $this->upload->do_upload('userfile'))
        {
            //fail
        }
        else
        {            
            $data = array('filename' => $this->upload->data());
        }

my view file

Code:
<?php $this->load->view('header'); ?>

<?php echo form_open_multipart('hasil_rad/do_upload');?>

<table width="546" border="0">
        <tr>
          <td>Hasil 3* </td>
          <td>:</td>
          <td>
            &lt;input type="text" name="hasil_3" size="40"&gt;
          </td>
        </tr>
        <tr>
          <td>Hasil 4* </td>
          <td>:</td>
          <td>
            &lt;input type="text" name="hasil_4" size="40"&gt;
          </td>
        </tr>
        <tr>
          <td>Hasil 5* </td>
          <td>:</td>
          <td>
            &lt;input type="text" name="hasil_5" size="40"&gt;
          </td>
<tr>
          <td>Gambar</td>
          <td>&nbsp;</td>
        
          <td>&lt;input type="file" name="userfile" /&gt;
           </td>
          <td>&lt;form id="form1" name="form1" method="post" &gt;
          </td>
      </tr>
</table>

i feel like i'm doing right,but the images were not uploaded to uploads right, any body can correct my codes?i can use upload form in CI user guide well, but i can't adapt those code to my view and controller file. my view file have 3 field and 1 upload form,and 1 save button. so if i click save button,then i upload image and i get content in all field. i can get content with $_POST, but the upload form doesn't work. why?


Messages In This Thread
Upload problem,newbie here please help :) - by El Forum - 04-24-2009, 08:35 PM
Upload problem,newbie here please help :) - by El Forum - 04-24-2009, 10:39 PM
Upload problem,newbie here please help :) - by El Forum - 04-25-2009, 01:46 AM
Upload problem,newbie here please help :) - by El Forum - 04-26-2009, 05:26 AM
Upload problem,newbie here please help :) - by El Forum - 04-26-2009, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB