Welcome Guest, Not a member yet? Register   Sign In
Please help me this code :()
#1

[eluser]java[/eluser]
I have built a controller that it included one function doUpload, like this:
Code:
class Dangky extends Controller {
    
    function Dangky()
    {
        parent::Controller();
        $this->load->helper('form','url');
        $this->load->model('tintuc_model', 'tintuc');
        $this->load->model('dangky_model', 'dangky');
    }
    
    function index()
    {
                $this->load->view('upload_form', array('error' => ' ' ));
                // and something...
        }
        function doUpload()
    {
            $config['upload_path'] = '/uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size']    = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
        
            $this->load->library('upload', $config);
            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
                $data['content'] = $this->load->view('dangky', $error, true);
            }    
            else
            {
            $contain_array = array('upload_data' => $this->upload->data());
                $this->db->set('file_name', $upload_data['file_name']);
            
                //$this->db->insert('my_database');
                $this->load->view('dangky', array('error' => ' ' ));    
            }
            
    }
and this is my form :
Code:
?=$error;?>
            <?=form_open_multipart('dangki/doUpload'); ?>
          <table cellspacing="0" cellpadding="5" width="100%" border="0">
              <colgroup>
              <col width="30%" />
              <col width="70%" />
              </colgroup>
              <tbody>
                <tr>
                  <td align="right">(<strong>*</strong>) Ảnh chân dung: </td>
  <td align="left">&lt;input id="fileUpPoitrait" type="file" name="fileUpPoitrait" /&gt;</td>
                </tr>
                <tr>
                  <td align="right">(<strong>*</strong>) Ảnh toàn thân: </td>
  <td align="left">&lt;input id="fileUpFullPicture" type="file" name="fileUpFullPicture" /&gt;</td>
                </tr>
                <tr>
                  <td align="right"> Xác nhận của nhà   trường: </td>
  <td align="left">&lt;input id="fileUpCertificate" type="file" name="fileUpCertificate" /&gt;
                  </td>
                </tr>
              </tbody>
          </table>
    &lt;/form&gt;
My form have 3 field wait to upload. i tried to solve my controller to save filename into database and store the image into some folder so that i can load it out to my page later. I dont know how to solve the path of the file name(it's save a full path of the image when upload). Please tell me how to perform it. I have read in user guide of CI but it's too simple and cannot resolve my problems.


Messages In This Thread
Please help me this code :() - by El Forum - 06-22-2007, 02:42 AM
Please help me this code :() - by El Forum - 06-22-2007, 03:14 AM
Please help me this code :() - by El Forum - 06-22-2007, 03:23 AM
Please help me this code :() - by El Forum - 06-22-2007, 04:23 AM
Please help me this code :() - by El Forum - 07-23-2009, 04:34 AM
Please help me this code :() - by El Forum - 07-07-2011, 03:37 AM
Please help me this code :() - by El Forum - 02-27-2012, 01:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB