Welcome Guest, Not a member yet? Register   Sign In
Still cannot upload file
#1

[eluser]thematrixuum[/eluser]
Here's my view :

Code:
<div id="upload_box" style="display:none"><h3>Upload File</h3>
                                &lt;form id="upload_form" enctype="multipart/form_data" method="post"&gt;
                                &lt;input type="file" name="userfile" /&gt;
                                <br /><br />
                                &lt;input type="submit" value="upload" /&gt;
                                &lt;/form&gt;</div>

Here's my controller :

Code:
public function upload_pro() {
        $this->template->set_output("xhr");
        $this->template->response = $this->klien->do_upload();
        $this->template->publish();    
    }

Here's a part of my model :

Code:
public function do_upload()
    {
        
        //array('error' => ' ' );
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
    
        if (!!$this->upload->do_upload($this->input->post('userfile')))
        {
                $data = array('upload_data' => $this->upload->data());
                return array(
                    'SUIXHR' => true,
                    'callback' => 'Js.widget.notice.success',
                    'text' => 'OK'
                );
        }    
        else
        {
            $error = $this->upload->display_errors();
                return array(
                    'SUIXHR' => true,
                    'callback' => 'Js.widget.notice.error',
                    'text' => $error
                );
        }
    }

can anybody help? is it because of mime type? because the error always showing 'You did not selected any file'..
#2

[eluser]umefarooq[/eluser]
hi check your form action is missing in that.
Code:
<h3>Upload File</h3>
&lt;form id="upload_form" enctype="multipart/form_data" method="post"&gt;
&lt;input type="file" name="userfile" /&gt;
<br /><br />
&lt;input type="submit" value="upload" /&gt;
&lt;/form&gt;
#3

[eluser]thematrixuum[/eluser]
the action is using javascript.. here, let me add the javascript, inside the view :
Code:
[removed]
&lt;!--
new Js.ext.formSubmit("#upload_form", "{{INDEX-URI}}client/upload_pro", "", "");
--&gt;
[removed]




Theme © iAndrew 2016 - Forum software by © MyBB